diff options
author | mitchell <70453897+667e-11@users.noreply.github.com> | 2009-01-27 12:34:25 -0500 |
---|---|---|
committer | mitchell <70453897+667e-11@users.noreply.github.com> | 2009-01-27 12:34:25 -0500 |
commit | bcf630f108fcb957b0a908b258fe3a644e189ceb (patch) | |
tree | 15fe72b3d5de757465431ecbb79154db36ae8308 | |
parent | f131668edad1ed20a3ac095925b602836503c8e8 (diff) |
Use a combo entry to either type in or select a PM browser to use.
-rw-r--r-- | core/ext/menu.lua | 33 | ||||
-rw-r--r-- | core/ext/pm/buffer_browser.lua | 2 | ||||
-rw-r--r-- | core/ext/pm/ctags_browser.lua | 2 | ||||
-rw-r--r-- | core/ext/pm/file_browser.lua | 2 | ||||
-rw-r--r-- | core/ext/pm/macro_browser.lua | 2 | ||||
-rw-r--r-- | core/ext/pm/modules_browser.lua | 2 | ||||
-rw-r--r-- | core/ext/pm/project_browser.lua | 2 | ||||
-rw-r--r-- | core/locale.lua | 19 | ||||
-rw-r--r-- | src/lua_interface.c | 8 | ||||
-rw-r--r-- | src/textadept.c | 5 |
10 files changed, 23 insertions, 54 deletions
diff --git a/core/ext/menu.lua b/core/ext/menu.lua index cc1ae5c6..13f1913e 100644 --- a/core/ext/menu.lua +++ b/core/ext/menu.lua @@ -115,15 +115,6 @@ local ID = { UNSPLIT_ALL_VIEWS = 606, GROW_VIEW = 607, SHRINK_VIEW = 608, - -- Project Manager - TOGGLE_PM_VISIBLE = 701, - FOCUS_PM = 702, - SHOW_PM_PROJECT = 703, - SHOW_PM_CTAGS = 704, - SHOW_PM_BUFFERS = 705, - SHOW_PM_FILES = 706, - SHOW_PM_MACROS = 707, - SHOW_PM_MODULES = 708, -- Lexers LEXER_ACTIONSCRIPT = 801, LEXER_ADA = 802, @@ -332,17 +323,6 @@ t.menubar = { { l.MENU_VIEW_SHRINK, ID.SHRINK_VIEW }, }, gtkmenu { - title = l.MENU_PM_TITLE, - { l.MENU_PM_TOGGLE_VISIBLE, ID.TOGGLE_PM_VISIBLE }, - { l.MENU_PM_FOCUS, ID.FOCUS_PM }, - { l.MENU_PM_BUFFERS, ID.SHOW_PM_BUFFERS }, - { l.MENU_PM_PROJECT, ID.SHOW_PM_PROJECT }, - { l.MENU_PM_FILES, ID.SHOW_PM_FILES }, - { l.MENU_PM_CTAGS, ID.SHOW_PM_CTAGS }, - { l.MENU_PM_MACROS, ID.SHOW_PM_MACROS }, - { l.MENU_PM_MODULES, ID.SHOW_PM_MODULES }, - }, - gtkmenu { title = l.MENU_LEX_TITLE, { 'actionscript', ID.LEXER_ACTIONSCRIPT }, { 'ada', ID.LEXER_ADA }, @@ -416,10 +396,6 @@ local m_bookmarks = _m.textadept.bookmarks local m_macros = _m.textadept.macros local m_run = _m.textadept.run -local function pm_activate(text) - t.pm.entry_text = text - t.pm.activate() -end local function toggle_setting(setting) local state = buffer[setting] if type(state) == 'boolean' then @@ -548,15 +524,6 @@ local actions = { [ID.SHRINK_VIEW] = { function() if view.size then view.size = view.size - 10 end end }, - -- Project Manager - [ID.TOGGLE_PM_VISIBLE] = { t.pm.toggle_visible }, - [ID.FOCUS_PM] = { t.pm.focus }, - [ID.SHOW_PM_PROJECT] = { pm_activate, 'project' }, - [ID.SHOW_PM_CTAGS] = { pm_activate, 'ctags' }, - [ID.SHOW_PM_BUFFERS] = { pm_activate, 'buffers' }, - [ID.SHOW_PM_FILES] = { pm_activate, not WIN32 and '/' or 'C:\\' }, - [ID.SHOW_PM_MACROS] = { pm_activate, 'macros' }, - [ID.SHOW_PM_MODULES] = { pm_activate, 'modules' }, } -- lexers here MUST be in the same order as in the menu diff --git a/core/ext/pm/buffer_browser.lua b/core/ext/pm/buffer_browser.lua index f9b69b8c..b92d2768 100644 --- a/core/ext/pm/buffer_browser.lua +++ b/core/ext/pm/buffer_browser.lua @@ -7,6 +7,8 @@ local textadept = _G.textadept -- It is enabled with the prefix 'buffers' in the project manager entry field. module('textadept.pm.browsers.buffer', package.seeall) +textadept.pm.add_browser('buffers') + function matches(entry_text) return entry_text:sub(1, 7) == 'buffers' end diff --git a/core/ext/pm/ctags_browser.lua b/core/ext/pm/ctags_browser.lua index 4de96096..3a4ce826 100644 --- a/core/ext/pm/ctags_browser.lua +++ b/core/ext/pm/ctags_browser.lua @@ -9,6 +9,8 @@ local textadept = _G.textadept -- is specified, the current file is parsed via ctags and its structure shown. module('textadept.pm.browsers.ctags', package.seeall) +textadept.pm.add_browser('ctags') + local FILE_OUT = '/tmp/textadept_output' --- diff --git a/core/ext/pm/file_browser.lua b/core/ext/pm/file_browser.lua index 3e95a2ce..ad70f75b 100644 --- a/core/ext/pm/file_browser.lua +++ b/core/ext/pm/file_browser.lua @@ -8,6 +8,8 @@ local textadept = _G.textadept -- manager entry field. module('textadept.pm.browsers.file', package.seeall) +textadept.pm.add_browser(not WIN32 and '/' or 'C:\\') + local lfs = require 'lfs' local os = require 'os' diff --git a/core/ext/pm/macro_browser.lua b/core/ext/pm/macro_browser.lua index eab11842..75e9e91f 100644 --- a/core/ext/pm/macro_browser.lua +++ b/core/ext/pm/macro_browser.lua @@ -7,6 +7,8 @@ local textadept = _G.textadept -- It is enabled with the prefix 'macros' in the project manager entry field. module('textadept.pm.browsers.macro', package.seeall) +textadept.pm.add_browser('macros') + function matches(entry_text) return entry_text:sub(1, 7) == 'macros' end diff --git a/core/ext/pm/modules_browser.lua b/core/ext/pm/modules_browser.lua index 9bcdd6df..174394a6 100644 --- a/core/ext/pm/modules_browser.lua +++ b/core/ext/pm/modules_browser.lua @@ -7,6 +7,8 @@ local textadept = _G.textadept -- It is enabled with the prefix 'modules' in the project manager entry field. module('textadept.pm.browsers.modules', package.seeall) +textadept.pm.add_browser('modules') + local lfs = require 'lfs' local os = require 'os' diff --git a/core/ext/pm/project_browser.lua b/core/ext/pm/project_browser.lua index 8c99194c..b1609ad1 100644 --- a/core/ext/pm/project_browser.lua +++ b/core/ext/pm/project_browser.lua @@ -7,6 +7,8 @@ local textadept = _G.textadept -- It is enabled with the prefix 'project' in the project manager entry field. module('textadept.pm.browsers.project', package.seeall) +textadept.pm.add_browser('project') + local lfs = require 'lfs' local os = require 'os' diff --git a/core/locale.lua b/core/locale.lua index 20895638..573b25be 100644 --- a/core/locale.lua +++ b/core/locale.lua @@ -325,25 +325,6 @@ MENU_VIEW_GROW = '_Grow' -- _Shrink MENU_VIEW_SHRINK = '_Shrink' --- _Project Manager -MENU_PM_TITLE = '_Project Manager' --- _Toggle Visible -MENU_PM_TOGGLE_VISIBLE = '_Toggle Visible' --- _Focus -MENU_PM_FOCUS = '_Focus' --- Show _Project -MENU_PM_PROJECT = 'Show _Project' --- Show _CTags -MENU_PM_CTAGS = 'Show _CTags' --- Show _Buffers -MENU_PM_BUFFERS = 'Show _Buffers' --- Show _Files -MENU_PM_FILES = 'Show _Files' --- Show _Macros -MENU_PM_MACROS = 'Show _Macros' --- Show Mo_dules -MENU_PM_MODULES = 'Show Mo_dules' - -- _Lexers MENU_LEX_TITLE = '_Lexers' diff --git a/src/lua_interface.c b/src/lua_interface.c index 71c1f07e..745ce368 100644 --- a/src/lua_interface.c +++ b/src/lua_interface.c @@ -67,6 +67,7 @@ static int l_cf_ta_buffer_new(lua_State *lua), l_cf_pm_focus(lua_State *lua), l_cf_pm_clear(lua_State *lua), l_cf_pm_activate(lua_State *lua), + l_cf_pm_add_browser(lua_State *lua), l_cf_find_focus(lua_State *lua), l_cf_call_find_next(lua_State *lua), l_cf_call_find_prev(lua_State *lua), @@ -117,6 +118,7 @@ bool l_init(int argc, char **argv, bool reinit) { l_cfunc(lua, l_cf_pm_focus, "focus"); l_cfunc(lua, l_cf_pm_clear, "clear"); l_cfunc(lua, l_cf_pm_activate, "activate"); + l_cfunc(lua, l_cf_pm_add_browser, "add_browser"); l_mt(lua, "_pm_mt", l_pm_mt_index, l_pm_mt_newindex); lua_setfield(lua, -2, "pm"); lua_newtable(lua); @@ -1557,6 +1559,12 @@ static int l_cf_pm_activate(lua_State *) { return 0; } +static int l_cf_pm_add_browser(lua_State *lua) { + GtkWidget *pm_combo = gtk_widget_get_parent(pm_entry); + gtk_combo_box_append_text(GTK_COMBO_BOX(pm_combo), lua_tostring(lua, -1)); + return 0; +} + static int l_cf_find_focus(lua_State *) { find_toggle_focus(); return 0; diff --git a/src/textadept.c b/src/textadept.c index 1cf899e0..6d9c98e7 100644 --- a/src/textadept.c +++ b/src/textadept.c @@ -588,9 +588,10 @@ void cfurlref_to_char(CFURLRef url, char *path, int len) { GtkWidget *pm_create_ui() { pm_container = gtk_vbox_new(FALSE, 1); - pm_entry = gtk_entry_new(); + GtkWidget *pm_combo = gtk_combo_box_entry_new_text(); + pm_entry = gtk_bin_get_child(GTK_BIN(pm_combo)); gtk_widget_set_name(pm_entry, "textadept-pm-entry"); - gtk_box_pack_start(GTK_BOX(pm_container), pm_entry, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(pm_container), pm_combo, FALSE, FALSE, 0); pm_store = gtk_tree_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); GtkTreeSortable *sortable = GTK_TREE_SORTABLE(pm_store); |