diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-04-19 21:29:38 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-04-19 22:17:39 +0530 |
| commit | 208202db9cba6ddf0713a70e7122c69a53b1f2aa (patch) | |
| tree | 747f8ad71c19f239e545d13579ccfa86c8fefe5e /src/LuaRuntimeApi.hpp | |
| parent | a9d767b209c503ac7b5dff5132aa213d47dcb608 (diff) | |
| download | null-browser-208202db9cba6ddf0713a70e7122c69a53b1f2aa.tar.gz null-browser-208202db9cba6ddf0713a70e7122c69a53b1f2aa.zip | |
Add web.search.get_text and prefill current search text
Diffstat (limited to 'src/LuaRuntimeApi.hpp')
| -rw-r--r-- | src/LuaRuntimeApi.hpp | 9 |
1 files changed, 9 insertions, 0 deletions
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}, |
