aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2009-01-26 16:54:56 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2009-01-26 16:54:56 -0500
commit10398566eb46ae7b76844c77501461ce1945755e (patch)
tree6c311fced5ec35db3a3d525fc1be7b890b321ca4
parentde75865048797117e548d894051a7ce76cbe4b05 (diff)
downloadtextadept-10398566eb46ae7b76844c77501461ce1945755e.tar.gz
textadept-10398566eb46ae7b76844c77501461ce1945755e.zip
Menu label text is irrelevant for PM menu actions due to l10n; focus on menu_id.
-rw-r--r--core/.browser.lua68
-rw-r--r--core/ext/pm.lua5
-rw-r--r--core/ext/pm/buffer_browser.lua2
-rw-r--r--core/ext/pm/ctags_browser.lua2
-rw-r--r--core/ext/pm/file_browser.lua2
-rw-r--r--core/ext/pm/macro_browser.lua2
-rw-r--r--core/ext/pm/modules_browser.lua2
-rw-r--r--core/ext/pm/project_browser.lua2
-rw-r--r--src/lua_interface.c9
-rw-r--r--src/textadept.c4
-rw-r--r--src/textadept.h2
11 files changed, 54 insertions, 46 deletions
diff --git a/core/.browser.lua b/core/.browser.lua
index d158ad15..a9ba1272 100644
--- a/core/.browser.lua
+++ b/core/.browser.lua
@@ -18,39 +18,55 @@ module('textadept.pm.browser')
function matches(entry_text)
---
--- This function is called for contents to show in the browser.
--- @param full_path An ordered list of parent IDs leading down to the selected
--- child (if expanding); the entry text is at the first index.
--- @param expanding Boolean indicating whether or not a parent is being
--- expanded.
--- @return table of contents to display. Each entry in the table is a key-value
--- pair. The key must be a string ID and the value a table. Three key-value
--- pairs are looked for in the table: parent, pixbuf, and display_text. parent
--- is an optional boolean indicating whether or not the item should be
--- identified as a parent (parents can be expanded so they have the arrow next
--- to them). pixbuf is an optional string specifying a GTK stock icon to be
--- associated with the item. text is a required string that is shown in the
--- project manager; it can have Pango markup. All other items in the table are
--- ignored.
+-- Requests treeview contents from browser that matches pm_entry's text.
+-- This function is called internally and shouldn't be called by a script.
+-- @param full_path A numerically indexed table of treeview item parents. The
+-- first index contains the text of pm_entry. Subsequent indexes contain the
+-- ID's of parents of the child requested for expanding (if any).
+-- @param expanding Optional flag indicating if the contents of a parent are
+-- being requested. Defaults to false.
+-- @return table of tables to for display in the treeview (single level).
+-- Each key in the return table is the treeview item's ID. The table value
+-- has the following recognized fields:
+-- parent - boolean value indicating if this entry can contain children. If
+-- true, an expanding arrow is displayed next to the entry.
+-- pixbuf - a string representing a GTK stock-id whose icon is displayed
+-- next to an entry.
+-- text - the entry's Pango marked-up display text.
+-- Note that only a SINGLE level of data needs to be returned. When parents
+-- are expanded, this function is called again to get that level of data.
function get_contents_for(full_path, expanding)
---
--- This function is called when a user selects an item in the browser.
--- @param selected_item An ordered list of parent IDs leading down to the
--- selected child; the entry text is at the first index.
+-- Performs an action based on the selected treeview item.
+-- This function is called internally and shouldn't be called by a script.
+-- @param selected_item Identical to 'full_path' in pm.get_contents_for.
+-- @see pm.get_contents_for
function perform_action(selected_item)
---
--- Requests a context menu for the selected item in the browser.
--- @param selected_item An ordered list of parent IDs leading down to the
--- selected child; the entry text is at the first index.
--- @return table used to construct a GTK menu.
--- @see textadept.gtkmenu
+-- Creates a context menu based on the selected treeview item.
+-- This function is called internally and shouldn't be called by a script.
+-- @param selected_item Identical to 'full_path' in pm.get_contents_for.
+-- @return table of menu items.
+-- The return table consists of an ordered list of strings to be used to
+-- construct a context menu. The strings are handled as follows:
+-- 'gtk-*' - a stock menu item is created based on the GTK stock-id.
+-- 'separator' - a menu separator item is created.
+-- Otherwise a regular menu item with a mnemonic is created.
+-- @see pm.get_contents_for
function get_context_menu(selected_item)
---
--- This function is called when a user selects a context menu item.
--- @param menu_item The text of the menu item selected.
--- @param selected_item An ordered list of parent IDs leading down to the
--- selected child; the entry text is at the first index.
+-- Performs an action based on the selected menu item.
+-- This function is called internally and shouldn't be called by a script.
+-- @param menu_id The numeric ID of the menu item.
+-- @param selected_item Identical to 'full_path' in pm.get_contents_for.
+-- @see pm.get_contents_for
function perform_menu_action(menu_item, selected_item)
+
+---
+-- Toggles the width of the project manager.
+-- If the pm is visible, it's width is saved and then set to 0, effectively
+-- hiding it. If it is hidden, the width is restored.
+function toggle_visible()
diff --git a/core/ext/pm.lua b/core/ext/pm.lua
index 8122c419..e70ae6e2 100644
--- a/core/ext/pm.lua
+++ b/core/ext/pm.lua
@@ -107,14 +107,13 @@ end
---
-- Performs an action based on the selected menu item.
-- This function is called internally and shouldn't be called by a script.
--- @param menu_item The label text of the menu item selected.
-- @param menu_id The numeric ID of the menu item.
-- @param selected_item Identical to 'full_path' in pm.get_contents_for.
-- @see pm.get_contents_for
-function pm.perform_menu_action(menu_item, menu_id, selected_item)
+function pm.perform_menu_action(menu_id, selected_item)
for _, browser in pairs(pm.browsers) do
if browser.matches(selected_item[1]) then
- return browser.perform_menu_action(menu_item, menu_id, selected_item)
+ return browser.perform_menu_action(menu_id, selected_item)
end
end
end
diff --git a/core/ext/pm/buffer_browser.lua b/core/ext/pm/buffer_browser.lua
index b2c04957..f9b69b8c 100644
--- a/core/ext/pm/buffer_browser.lua
+++ b/core/ext/pm/buffer_browser.lua
@@ -46,7 +46,7 @@ function get_context_menu(selected_item)
}
end
-function perform_menu_action(menu_item, menu_id, selected_item)
+function perform_menu_action(menu_id, selected_item)
if menu_id == ID.NEW then
textadept.new_buffer()
elseif menu_id == ID.OPEN then
diff --git a/core/ext/pm/ctags_browser.lua b/core/ext/pm/ctags_browser.lua
index 8f112470..4de96096 100644
--- a/core/ext/pm/ctags_browser.lua
+++ b/core/ext/pm/ctags_browser.lua
@@ -232,7 +232,7 @@ function get_context_menu(selected_item)
end
-function perform_menu_action(menu_item, menu_id, selected_item)
+function perform_menu_action(menu_id, selected_item)
end
diff --git a/core/ext/pm/file_browser.lua b/core/ext/pm/file_browser.lua
index 7c03518a..3e95a2ce 100644
--- a/core/ext/pm/file_browser.lua
+++ b/core/ext/pm/file_browser.lua
@@ -51,7 +51,7 @@ function get_context_menu(selected_item)
}
end
-function perform_menu_action(menu_item, menu_id, selected_item)
+function perform_menu_action(menu_id, selected_item)
local locale = textadept.locale
local filepath = table.concat(selected_item, '/')
if menu_id == ID.CHANGE_DIR then
diff --git a/core/ext/pm/macro_browser.lua b/core/ext/pm/macro_browser.lua
index 051487cf..eab11842 100644
--- a/core/ext/pm/macro_browser.lua
+++ b/core/ext/pm/macro_browser.lua
@@ -30,7 +30,7 @@ function get_context_menu(selected_item)
return { { locale.PM_BROWSER_MACRO_DELETE, ID.DELETE } }
end
-function perform_menu_action(menu_item, menu_id, selected_item)
+function perform_menu_action(menu_id, selected_item)
local m_macros = _m.textadept.macros
if menu_id == ID.DELETE then
m_macros.delete(selected_item[2])
diff --git a/core/ext/pm/modules_browser.lua b/core/ext/pm/modules_browser.lua
index 5cf93d25..9bcdd6df 100644
--- a/core/ext/pm/modules_browser.lua
+++ b/core/ext/pm/modules_browser.lua
@@ -122,7 +122,7 @@ function get_context_menu(selected_item)
}
end
-function perform_menu_action(menu_item, menu_id, selected_item)
+function perform_menu_action(menu_id, selected_item)
local locale = textadept.locale
if menu_id == ID.NEW then
local status, module_name =
diff --git a/core/ext/pm/project_browser.lua b/core/ext/pm/project_browser.lua
index 9a6c078a..8c99194c 100644
--- a/core/ext/pm/project_browser.lua
+++ b/core/ext/pm/project_browser.lua
@@ -98,7 +98,7 @@ function get_context_menu(selected_item)
}
end
-function perform_menu_action(menu_item, menu_id, selected_item)
+function perform_menu_action(menu_id, selected_item)
local locale = textadept.locale
if menu_id == ID.NEW then
-- Close all open files and prompt the user to save a project file.
diff --git a/src/lua_interface.c b/src/lua_interface.c
index 02771be1..023bd7c0 100644
--- a/src/lua_interface.c
+++ b/src/lua_interface.c
@@ -350,8 +350,6 @@ int l_add_scintilla_buffer(sptr_t doc) {
lua_newtable(lua);
lua_pushnumber(lua, doc);
lua_setfield(lua, -2, "doc_pointer");
- lua_pushboolean(lua, false);
- lua_setfield(lua, -2, "dirty");
l_cfunc(lua, l_cf_buffer_find, "find");
l_cfunc(lua, l_cf_buffer_text_range, "text_range");
l_cfunc(lua, l_cf_buffer_delete, "delete");
@@ -969,17 +967,14 @@ void l_pm_perform_action() {
* Performs a selected menu action from an item's context menu in the Project
* Manager.
* The full path table for the item is at the top of the Lua stack.
- * @param menu_item The label text for the menu item clicked.
* @param menu_id The numeric ID for the menu item.
*/
-void l_pm_perform_menu_action(const char *menu_item, int menu_id) {
+void l_pm_perform_menu_action(int menu_id) {
if (!l_is_ta_table_function("pm", "perform_menu_action")) return;
l_insert(lua, -1); // shift full_path down
- lua_pushstring(lua, menu_item);
- l_insert(lua, -1); // shift full_path down
lua_pushnumber(lua, menu_id);
l_insert(lua, -1); // shift full_path down
- l_call_function(3);
+ l_call_function(2);
}
// Find/Replace
diff --git a/src/textadept.c b/src/textadept.c
index 2ab4091c..b85dcabb 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -774,13 +774,11 @@ void pm_popup_context_menu(GdkEventButton *event) {
* @see l_pm_perform_menu_action
*/
void pm_process_selected_menu_item(GtkWidget *menu_item, int menu_id) {
- GtkWidget *label = gtk_bin_get_child(GTK_BIN(menu_item));
- const char *text = gtk_label_get_text(GTK_LABEL(label));
GtkTreePath *path;
GtkTreeViewColumn *column;
gtk_tree_view_get_cursor(GTK_TREE_VIEW(pm_view), &path, &column);
l_pm_get_full_path(path);
- l_pm_perform_menu_action(text, menu_id);
+ l_pm_perform_menu_action(menu_id);
}
/**
diff --git a/src/textadept.h b/src/textadept.h
index c0677ae2..f991cc77 100644
--- a/src/textadept.h
+++ b/src/textadept.h
@@ -98,7 +98,7 @@ void l_pm_populate(GtkTreeIter *initial_iter);
void l_pm_get_full_path(GtkTreePath *path);
void l_pm_perform_action();
void l_pm_popup_context_menu(GdkEventButton *event, GCallback callback);
-void l_pm_perform_menu_action(const char *menu_item, int menu_id);
+void l_pm_perform_menu_action(int menu_id);
void l_find(const char *ftext, bool next);
void l_find_replace(const char *rtext);