From 208202db9cba6ddf0713a70e7122c69a53b1f2aa Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 19 Apr 2025 21:29:38 +0530 Subject: Add web.search.get_text and prefill current search text --- src/LuaRuntimeApi.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/LuaRuntimeApi.hpp') diff --git a/src/LuaRuntimeApi.hpp b/src/LuaRuntimeApi.hpp index ff2f46c..3b67f36 100644 --- a/src/LuaRuntimeApi.hpp +++ b/src/LuaRuntimeApi.hpp @@ -4,6 +4,7 @@ #include "LuaRuntime.hpp" #include "WindowActionRouter.hpp" +#include "lua.h" int lua_api_view_set_url(lua_State *state) { const char *url = lua_tostring(state, 1); @@ -216,6 +217,13 @@ int lua_api_view_open_devtools(lua_State *state) { return 1; } +int lua_api_search_get_text(lua_State *state) { + auto &router = WindowActionRouter::instance(); + auto search_text = router.fetch_current_search_text(); + lua_pushstring(state, search_text.toStdString().c_str()); + return 1; +} + // NOLINTNEXTLINE static luaL_Reg internals_api[] = { luaL_Reg{"event_add_listener", &lua_event_register}, @@ -230,6 +238,7 @@ static luaL_Reg internals_api[] = { 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_get_text", &lua_api_search_get_text}, 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}, -- cgit v1.3.1