aboutsummaryrefslogtreecommitdiffhomepage
path: root/core
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+667e-11@users.noreply.github.com>2009-01-26 16:54:56 -0500
committerGravatar mitchell <70453897+667e-11@users.noreply.github.com>2009-01-26 16:54:56 -0500
commit10398566eb46ae7b76844c77501461ce1945755e (patch)
tree6c311fced5ec35db3a3d525fc1be7b890b321ca4 /core
parentde75865048797117e548d894051a7ce76cbe4b05 (diff)
Menu label text is irrelevant for PM menu actions due to l10n; focus on menu_id.
Diffstat (limited to 'core')
-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
8 files changed, 50 insertions, 35 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.