aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2008-11-08 23:40:50 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2008-11-08 23:40:50 -0500
commit4ac940a813d54ff401db80c7c6f1ba80bfbe7802 (patch)
treedb9e0ba8cd1faa375527d238ea48b5da15ff9352
parent0ebcbf679cd1c31ebae6af640869df98675add4f (diff)
downloadtextadept-4ac940a813d54ff401db80c7c6f1ba80bfbe7802.tar.gz
textadept-4ac940a813d54ff401db80c7c6f1ba80bfbe7802.zip
Added Lua interface functions to mimick find box button presses.
-rw-r--r--core/.find.lua16
-rw-r--r--core/ext/menu.lua9
-rw-r--r--src/lua_interface.c53
-rw-r--r--src/textadept.h3
4 files changed, 72 insertions, 9 deletions
diff --git a/core/.find.lua b/core/.find.lua
index c6eabed1..043979cb 100644
--- a/core/.find.lua
+++ b/core/.find.lua
@@ -64,3 +64,19 @@ function find.replace(rtext) end
-- @param flags The number mask identical to the one in 'find'.
-- @see find.find
function find.replace_all(ftext, rtext, flags) end
+
+---
+-- Mimicks a press of the 'Find Next' button in the Find box.
+function find.call_find_next() end
+
+---
+-- Mimicks a press of the 'Find Prev' button in the Find box.
+function find.call_find_prev() end
+
+---
+-- Mimicks a press of the 'Replace' button in the Find box.
+function find.call_replace() end
+
+---
+-- Mimicks a press of the 'Replace All' button in the Find box.
+function find.call_replace_all() end
diff --git a/core/ext/menu.lua b/core/ext/menu.lua
index 459d3f61..913155fb 100644
--- a/core/ext/menu.lua
+++ b/core/ext/menu.lua
@@ -88,6 +88,8 @@ t.menubar = {
'Find _Next',
'Find _Prev',
'gtk-find-and-replace',
+ 'Replace',
+ 'Replace _All',
'separator',
'gtk-jump-to',
},
@@ -244,10 +246,11 @@ local actions = {
Scope = { m_editing.select_scope },
-- Search
Find = { t.find.focus },
- ['Find Next'] = { }, -- TODO:
- ['Find Prev'] = { }, -- TODO:
- Replace = { }, -- TODO:
+ ['Find Next'] = { t.find.call_find_next },
+ ['Find Prev'] = { t.find.call_find_prev },
['Find and Replace'] = { t.find.focus },
+ Replace = { t.find.call_replace },
+ ['Replace All'] = { t.find.call_replace_all },
['Jump to'] = { m_editing.goto_line },
-- Tools
['Focus Command Entry'] = { t.command_entry.focus },
diff --git a/src/lua_interface.c b/src/lua_interface.c
index 8977cbd8..79f27916 100644
--- a/src/lua_interface.c
+++ b/src/lua_interface.c
@@ -52,6 +52,8 @@ LF l_cf_ta_buffer_new(LS *lua),
l_cf_ta_reset(LS *lua),
l_cf_pm_focus(LS *lua), l_cf_pm_clear(LS *lua), l_cf_pm_activate(LS *lua),
l_cf_find_focus(LS *lua),
+ l_cf_call_find_next(LS *lua), l_cf_call_find_prev(LS *lua),
+ l_cf_call_replace(LS *lua), l_cf_call_replace_all(LS *lua),
l_cf_ce_focus(LS *lua);
const char
@@ -98,6 +100,10 @@ bool l_init(int argc, char **argv, bool reinit) {
lua_setfield(lua, -2, "pm");
lua_newtable(lua);
l_cfunc(lua, l_cf_find_focus, "focus");
+ l_cfunc(lua, l_cf_call_find_next, "call_find_next");
+ l_cfunc(lua, l_cf_call_find_prev, "call_find_prev");
+ l_cfunc(lua, l_cf_call_replace, "call_replace");
+ l_cfunc(lua, l_cf_call_replace_all, "call_replace_all");
l_mt(lua, "_find_mt", l_find_mt_index, l_find_mt_newindex);
lua_setfield(lua, -2, "find");
lua_newtable(lua);
@@ -1385,10 +1391,47 @@ LF l_cf_ta_reset(LS *lua) {
return 0;
}
-LF l_cf_pm_focus(LS *) { pm_toggle_focus(); return 0; }
-LF l_cf_pm_clear(LS *) { gtk_tree_store_clear(pm_store); return 0; }
+LF l_cf_pm_focus(LS *) {
+ pm_toggle_focus();
+ return 0;
+}
+
+LF l_cf_pm_clear(LS *) {
+ gtk_tree_store_clear(pm_store);
+ return 0;
+}
+
LF l_cf_pm_activate(LS *) {
- g_signal_emit_by_name(G_OBJECT(pm_entry), "activate"); return 0;
+ g_signal_emit_by_name(G_OBJECT(pm_entry), "activate");
+ return 0;
+}
+
+LF l_cf_find_focus(LS *) {
+ find_toggle_focus();
+ return 0;
+}
+
+LF l_cf_call_find_next(LS *) {
+ g_signal_emit_by_name(G_OBJECT(fnext_button), "clicked");
+ return 0;
+}
+
+LF l_cf_call_find_prev(LS *) {
+ g_signal_emit_by_name(G_OBJECT(fprev_button), "clicked");
+ return 0;
+}
+
+LF l_cf_call_replace(LS *) {
+ g_signal_emit_by_name(G_OBJECT(r_button), "clicked");
+ return 0;
+}
+
+LF l_cf_call_replace_all(LS *) {
+ g_signal_emit_by_name(G_OBJECT(ra_button), "clicked");
+ return 0;
+}
+
+LF l_cf_ce_focus(LS *) {
+ ce_toggle_focus();
+ return 0;
}
-LF l_cf_find_focus(LS *) { find_toggle_focus(); return 0; }
-LF l_cf_ce_focus(LS *) { ce_toggle_focus(); return 0; }
diff --git a/src/textadept.h b/src/textadept.h
index 4b042a27..d2ef9376 100644
--- a/src/textadept.h
+++ b/src/textadept.h
@@ -33,7 +33,8 @@ using namespace Scintilla;
extern GtkWidget
*window, *focused_editor, *command_entry,
*pm_container, *pm_entry, *pm_view,
- *findbox, *find_entry, *replace_entry;
+ *findbox, *find_entry, *replace_entry,
+ *fnext_button, *fprev_button, *r_button, *ra_button;
extern GtkEntryCompletion *command_entry_completion;
extern GtkTreeStore *cec_store, *pm_store;
extern lua_State *lua;