diff options
-rw-r--r-- | core/ext/menu.lua | 26 | ||||
-rw-r--r-- | core/locale.conf | 16 |
2 files changed, 41 insertions, 1 deletions
diff --git a/core/ext/menu.lua b/core/ext/menu.lua index 3d5bc83c..25e9950c 100644 --- a/core/ext/menu.lua +++ b/core/ext/menu.lua @@ -125,6 +125,9 @@ local ID = { SHRINK_VIEW = 608, -- Lexers (will be generated dynamically) LEXER_START = 801, + -- Help + MANUAL = 901, + LUADOC = 902, } @@ -281,6 +284,12 @@ local menubar = { { l.MENU_VIEW_GROW, ID.GROW_VIEW }, { l.MENU_VIEW_SHRINK, ID.SHRINK_VIEW }, }, + -- Lexer menu inserted here + gtkmenu { + title = l.MENU_HELP_TITLE, + { l.MENU_HELP_MANUAL, ID.MANUAL }, + { l.MENU_HELP_LUADOC, ID.LUADOC }, + }, } local lexers = {} local lexer_menu = { title = l.MENU_LEX_TITLE } @@ -294,7 +303,7 @@ table.sort(lexers) for _, lexer in ipairs(lexers) do lexer_menu[#lexer_menu + 1] = { lexer, ID.LEXER_START + #lexer_menu } end -menubar[#menubar + 1] = gtkmenu(lexer_menu) +table.insert(menubar, #menubar, gtkmenu(lexer_menu)) -- before 'Help' t.menubar = menubar local b, v = 'buffer', 'view' @@ -327,6 +336,18 @@ local function set_lexer_language(lexer) buffer:colourise(0, -1) t.events.update_ui() -- for updating statusbar end +local function open_webpage(url) + local cmd + if not WIN32 then + cmd = + string.format('"%s" "file://%s"', not MAC and 'firefox' or 'open', url) + else + cmd = + string.format('"%s" %s', + 'c:/program files/internet explorer/iexplore.exe', url) + end + if os.execute(cmd) ~= 0 then error(l.MENU_BROWSER_ERROR) end +end local actions = { -- File @@ -453,6 +474,9 @@ local actions = { [ID.SHRINK_VIEW] = { function() if view.size then view.size = view.size - 10 end end }, + -- Help + [ID.MANUAL] = { open_webpage, _HOME..'/doc/manual.html' }, + [ID.LUADOC] = { open_webpage, _HOME..'/doc/index.html' }, } if MAC then actions[ID.PASTE] = { m_editing.smart_paste } end -- fix paste issue diff --git a/core/locale.conf b/core/locale.conf index 50834bf9..98f48b97 100644 --- a/core/locale.conf +++ b/core/locale.conf @@ -632,6 +632,22 @@ MENU_VIEW_SHRINK "_Shrink" MENU_LEX_TITLE "_Lexers" % core/ext/menu.lua +% "_Help" +MENU_HELP_TITLE "_Help" + +% core/ext/menu.lua +% "_Manual" +MENU_HELP_MANUAL "_Manual" + +% core/ext/menu.lua +% "_LuaDoc" +MENU_HELP_LUADOC "_LuaDoc" + +% core/ext/menu.lua +% "Error loading webpage.\nCheck the browser path in core/ext/menu.lua" +MENU_BROWSER_ERROR "Error loading webpage.\nCheck the browser path in core/ext/menu.lua" + +% core/ext/menu.lua % "Unknown command: " MENU_UNKNOWN_COMMAND "Unknown command: " |