aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept/menu.lua
diff options
context:
space:
mode:
Diffstat (limited to 'modules/textadept/menu.lua')
-rw-r--r--modules/textadept/menu.lua303
1 files changed, 152 insertions, 151 deletions
diff --git a/modules/textadept/menu.lua b/modules/textadept/menu.lua
index 70fc406d..8cb7bc1c 100644
--- a/modules/textadept/menu.lua
+++ b/modules/textadept/menu.lua
@@ -1,9 +1,6 @@
-- Copyright 2007-2011 Mitchell mitchell<att>caladbolg.net. See LICENSE.
-- Contributions from Robert Gieseke.
-local L = locale.localize
-local gui = gui
-
local M = {}
--[[ This comment is for LuaDoc.
@@ -13,7 +10,7 @@ local M = {}
-- looks up defined key commands to show them in menus.
module('_m.textadept.menu')]]
-local _buffer, _view = buffer, view
+local _L, gui, _buffer, _view = _L, gui, buffer, view
local m_textadept, m_editing = _m.textadept, _m.textadept.editing
local c, SEPARATOR = _SCINTILLA.constants, { 'separator' }
local utils = m_textadept.keys.utils
@@ -36,184 +33,188 @@ end
-- @class table
-- @name menubar
M.menubar = {
- { title = L('File'),
- { L('gtk-new'), new_buffer },
- { L('gtk-open'), io.open_file },
- { L('Open Recent...'), io.open_recent_file },
- { L('Reload'), _buffer.reload },
- { L('gtk-save'), _buffer.save },
- { L('gtk-save-as'), _buffer.save_as },
+ { title = _L['File'],
+ { _L['gtk-new'], new_buffer },
+ { _L['gtk-open'], io.open_file },
+ { _L['Open Recent...'], io.open_recent_file },
+ { _L['Reload'], _buffer.reload },
+ { _L['gtk-save'], _buffer.save },
+ { _L['gtk-save-as'], _buffer.save_as },
SEPARATOR,
- { L('gtk-close'), _buffer.close },
- { L('Close All'), io.close_all },
+ { _L['gtk-close'], _buffer.close },
+ { _L['Close All'], io.close_all },
SEPARATOR,
- { L('Load Session...'), m_textadept.session.prompt_load },
- { L('Save Session...'), m_textadept.session.prompt_save },
+ { _L['Load Session...'], m_textadept.session.prompt_load },
+ { _L['Save Session...'], m_textadept.session.prompt_save },
SEPARATOR,
- { L('gtk-quit'), quit },
+ { _L['gtk-quit'], quit },
},
- { title = L('Edit'),
- { L('gtk-undo'), _buffer.undo },
- { L('gtk-redo'), _buffer.redo },
+ { title = _L['Edit'],
+ { _L['gtk-undo'], _buffer.undo },
+ { _L['gtk-redo'], _buffer.redo },
SEPARATOR,
- { L('gtk-cut'), _buffer.cut },
- { L('gtk-copy'), _buffer.copy },
- { L('gtk-paste'), _buffer.paste },
- { L('Duplicate Line'), _buffer.line_duplicate },
- { L('gtk-delete'), _buffer.clear },
- { L('gtk-select-all'), _buffer.select_all },
+ { _L['gtk-cut'], _buffer.cut },
+ { _L['gtk-copy'], _buffer.copy },
+ { _L['gtk-paste'], _buffer.paste },
+ { _L['Duplicate Line'], _buffer.line_duplicate },
+ { _L['gtk-delete'], _buffer.clear },
+ { _L['gtk-select-all'], _buffer.select_all },
SEPARATOR,
- { L('Match Brace'), m_editing.match_brace },
- { L('Complete Word'), { m_editing.autocomplete_word, '%w_' } },
- { L('Delete Word'), { m_editing.current_word, 'delete' } },
- { L('Highlight Word'), m_editing.highlight_word },
- { L('Toggle Block Comment'), m_editing.block_comment },
- { L('Transpose Characters'), m_editing.transpose_chars },
- { L('Join Lines'), m_editing.join_lines },
- { title = L('Select'),
- { L('Select to Matching Brace'), { m_editing.match_brace, 'select' } },
- { L('Select between XML Tags'), { m_editing.select_enclosed, '>', '<' } },
- { L('Select in XML Tag'), { m_editing.select_enclosed, '<', '>' } },
- { L('Select in Single Quotes'), { m_editing.select_enclosed, "'", "'" } },
- { L('Select in Double Quotes'), { m_editing.select_enclosed, '"', '"' } },
- { L('Select in Parentheses'), { m_editing.select_enclosed, '(', ')' } },
- { L('Select in Brackets'), { m_editing.select_enclosed, '[', ']' } },
- { L('Select in Braces'), { m_editing.select_enclosed, '{', '}' } },
- { L('Select Word'), { m_editing.current_word, 'select' } },
- { L('Select Line'), m_editing.select_line },
- { L('Select Paragraph'), m_editing.select_paragraph },
- { L('Select Indented Block'), m_editing.select_indented_block },
+ { _L['Match Brace'], m_editing.match_brace },
+ { _L['Complete Word'], { m_editing.autocomplete_word, '%w_' } },
+ { _L['Delete Word'], { m_editing.current_word, 'delete' } },
+ { _L['Highlight Word'], m_editing.highlight_word },
+ { _L['Toggle Block Comment'], m_editing.block_comment },
+ { _L['Transpose Characters'], m_editing.transpose_chars },
+ { _L['Join Lines'], m_editing.join_lines },
+ { title = _L['Select'],
+ { _L['Select to Matching Brace'], { m_editing.match_brace, 'select' } },
+ { _L['Select between XML Tags'],
+ { m_editing.select_enclosed, '>', '<' } },
+ { _L['Select in XML Tag'], { m_editing.select_enclosed, '<', '>' } },
+ { _L['Select in Single Quotes'],
+ { m_editing.select_enclosed, "'", "'" } },
+ { _L['Select in Double Quotes'],
+ { m_editing.select_enclosed, '"', '"' } },
+ { _L['Select in Parentheses'], { m_editing.select_enclosed, '(', ')' } },
+ { _L['Select in Brackets'], { m_editing.select_enclosed, '[', ']' } },
+ { _L['Select in Braces'], { m_editing.select_enclosed, '{', '}' } },
+ { _L['Select Word'], { m_editing.current_word, 'select' } },
+ { _L['Select Line'], m_editing.select_line },
+ { _L['Select Paragraph'], m_editing.select_paragraph },
+ { _L['Select Indented Block'], m_editing.select_indented_block },
},
- { title = L('Selection'),
- { L('Upper Case Selection'), _buffer.upper_case },
- { L('Lower Case Selection'), _buffer.lower_case },
+ { title = _L['Selection'],
+ { _L['Upper Case Selection'], _buffer.upper_case },
+ { _L['Lower Case Selection'], _buffer.lower_case },
SEPARATOR,
- { L('Enclose as XML Tags'), utils.enclose_as_xml_tags },
- { L('Enclose as Single XML Tag'), { m_editing.enclose, '<', ' />' } },
- { L('Enclose in Single Quotes'), { m_editing.enclose, "'", "'" } },
- { L('Enclose in Double Quotes'), { m_editing.enclose, '"', '"' } },
- { L('Enclose in Parentheses'), { m_editing.enclose, '(', ')' } },
- { L('Enclose in Brackets'), { m_editing.enclose, '[', ']' } },
- { L('Enclose in Braces'), { m_editing.enclose, '{', '}' } },
+ { _L['Enclose as XML Tags'], utils.enclose_as_xml_tags },
+ { _L['Enclose as Single XML Tag'], { m_editing.enclose, '<', ' />' } },
+ { _L['Enclose in Single Quotes'], { m_editing.enclose, "'", "'" } },
+ { _L['Enclose in Double Quotes'], { m_editing.enclose, '"', '"' } },
+ { _L['Enclose in Parentheses'], { m_editing.enclose, '(', ')' } },
+ { _L['Enclose in Brackets'], { m_editing.enclose, '[', ']' } },
+ { _L['Enclose in Braces'], { m_editing.enclose, '{', '}' } },
SEPARATOR,
- { L('Grow Selection'), { m_editing.grow_selection, 1 } },
- { L('Shrink Selection'), { m_editing.grow_selection, -1 } },
+ { _L['Grow Selection'], { m_editing.grow_selection, 1 } },
+ { _L['Shrink Selection'], { m_editing.grow_selection, -1 } },
SEPARATOR,
- { L('Move Selected Lines Up'), _buffer.move_selected_lines_up },
- { L('Move Selected Lines Down'), _buffer.move_selected_lines_down },
+ { _L['Move Selected Lines Up'], _buffer.move_selected_lines_up },
+ { _L['Move Selected Lines Down'], _buffer.move_selected_lines_down },
},
},
- { title = L('Search'),
- { L('gtk-find'), gui.find.focus },
- { L('Find Next'), gui.find.find_next },
- { L('Find Previous'), gui.find.find_prev },
- { L('Replace'), gui.find.replace },
- { L('Replace All'), gui.find.replace_all },
- { L('Find Incremental'), gui.find.find_incremental },
+ { title = _L['Search'],
+ { _L['gtk-find'], gui.find.focus },
+ { _L['Find Next'], gui.find.find_next },
+ { _L['Find Previous'], gui.find.find_prev },
+ { _L['Replace'], gui.find.replace },
+ { _L['Replace All'], gui.find.replace_all },
+ { _L['Find Incremental'], gui.find.find_incremental },
SEPARATOR,
- { L('Find in Files'), utils.find_in_files },
- { L('Goto Next File Found'), { gui.find.goto_file_in_list, true } },
- { L('Goto Previous File Found'), { gui.find.goto_file_in_list, false } },
+ { _L['Find in Files'], utils.find_in_files },
+ { _L['Goto Next File Found'], { gui.find.goto_file_in_list, true } },
+ { _L['Goto Previous File Found'], { gui.find.goto_file_in_list, false } },
SEPARATOR,
- { L('gtk-jump-to'), m_editing.goto_line },
+ { _L['gtk-jump-to'], m_editing.goto_line },
},
- { title = L('Tools'),
- { L('Command Entry'), gui.command_entry.focus },
- { L('Select Command'), utils.select_command },
+ { title = _L['Tools'],
+ { _L['Command Entry'], gui.command_entry.focus },
+ { _L['Select Command'], utils.select_command },
SEPARATOR,
- { L('Run'), m_textadept.run.run },
- { L('Compile'), m_textadept.run.compile },
- { L('Filter Through'), _m.textadept.filter_through.filter_through },
+ { _L['Run'], m_textadept.run.run },
+ { _L['Compile'], m_textadept.run.compile },
+ { _L['Filter Through'], _m.textadept.filter_through.filter_through },
SEPARATOR,
- { title = L('Adeptsense'),
- { L('Complete Symbol'), m_textadept.adeptsense.complete_symbol },
- { L('Show Documentation'), m_textadept.adeptsense.show_documentation },
+ { title = _L['Adeptsense'],
+ { _L['Complete Symbol'], m_textadept.adeptsense.complete_symbol },
+ { _L['Show Documentation'], m_textadept.adeptsense.show_documentation },
},
- { title = L('Bookmark'),
- { L('Toggle Bookmark'), m_textadept.bookmarks.toggle },
- { L('Clear Bookmarks'), m_textadept.bookmarks.clear },
- { L('Next Bookmark'), m_textadept.bookmarks.goto_next },
- { L('Previous Bookmark'), m_textadept.bookmarks.goto_prev },
- { L('Goto Bookmark...'), m_textadept.bookmarks.goto_bookmark },
+ { title = _L['Bookmark'],
+ { _L['Toggle Bookmark'], m_textadept.bookmarks.toggle },
+ { _L['Clear Bookmarks'], m_textadept.bookmarks.clear },
+ { _L['Next Bookmark'], m_textadept.bookmarks.goto_next },
+ { _L['Previous Bookmark'], m_textadept.bookmarks.goto_prev },
+ { _L['Goto Bookmark...'], m_textadept.bookmarks.goto_bookmark },
},
- { title = L('Snapopen'),
- { L('Snapopen User Home'), { m_textadept.snapopen.open, _USERHOME } },
- { L('Snapopen Textadept Home'), { m_textadept.snapopen.open, _HOME } },
- { L('Snapopen Current Directory'), utils.snapopen_filedir },
+ { title = _L['Snapopen'],
+ { _L['Snapopen User Home'], { m_textadept.snapopen.open, _USERHOME } },
+ { _L['Snapopen Textadept Home'], { m_textadept.snapopen.open, _HOME } },
+ { _L['Snapopen Current Directory'], utils.snapopen_filedir },
},
- { title = L('Snippets'),
- { L('Insert Snippet...'), m_textadept.snippets._select },
- { L('Expand Snippet/Next Placeholder'), m_textadept.snippets._insert },
- { L('Previous Snippet Placeholder'), m_textadept.snippets._previous },
- { L('Cancel Snippet'), m_textadept.snippets._cancel_current },
+ { title = _L['Snippets'],
+ { _L['Insert Snippet...'], m_textadept.snippets._select },
+ { _L['Expand Snippet/Next Placeholder'], m_textadept.snippets._insert },
+ { _L['Previous Snippet Placeholder'], m_textadept.snippets._previous },
+ { _L['Cancel Snippet'], m_textadept.snippets._cancel_current },
},
SEPARATOR,
- { L('Show Style'), utils.show_style },
+ { _L['Show Style'], utils.show_style },
},
- { title = L('Buffer'),
- { L('Next Buffer'), { _view.goto_buffer, _view, 1, true } },
- { L('Previous Buffer'), { _view.goto_buffer, _view, -1, true } },
- { L('Switch to Buffer...'), gui.switch_buffer },
+ { title = _L['Buffer'],
+ { _L['Next Buffer'], { _view.goto_buffer, _view, 1, true } },
+ { _L['Previous Buffer'], { _view.goto_buffer, _view, -1, true } },
+ { _L['Switch to Buffer...'], gui.switch_buffer },
SEPARATOR,
- { title = L('Indentation'),
- { L('Tab width: 2'), { utils.set_indentation, 2 } },
- { L('Tab width: 3'), { utils.set_indentation, 3 } },
- { L('Tab width: 4'), { utils.set_indentation, 4 } },
- { L('Tab width: 8'), { utils.set_indentation, 8 } },
+ { title = _L['Indentation'],
+ { _L['Tab width: 2'], { utils.set_indentation, 2 } },
+ { _L['Tab width: 3'], { utils.set_indentation, 3 } },
+ { _L['Tab width: 4'], { utils.set_indentation, 4 } },
+ { _L['Tab width: 8'], { utils.set_indentation, 8 } },
SEPARATOR,
- { L('Toggle Use Tabs'), { utils.toggle_property, 'use_tabs' } },
- { L('Convert Indentation'), m_editing.convert_indentation },
+ { _L['Toggle Use Tabs'], { utils.toggle_property, 'use_tabs' } },
+ { _L['Convert Indentation'], m_editing.convert_indentation },
},
- { title = L('EOL Mode'),
- { L('CRLF'), { utils.set_eol_mode, c.SC_EOL_CRLF } },
- { L('CR'), { utils.set_eol_mode, c.SC_EOL_CR } },
- { L('LF'), { utils.set_eol_mode, c.SC_EOL_LF } },
+ { title = _L['EOL Mode'],
+ { _L['CRLF'], { utils.set_eol_mode, c.SC_EOL_CRLF } },
+ { _L['CR'], { utils.set_eol_mode, c.SC_EOL_CR } },
+ { _L['LF'], { utils.set_eol_mode, c.SC_EOL_LF } },
},
- { title = L('Encoding'),
- { L('UTF-8 Encoding'), { utils.set_encoding, 'UTF-8' } },
- { L('ASCII Encoding'), { utils.set_encoding, 'ASCII' } },
- { L('ISO-8859-1 Encoding'), { utils.set_encoding, 'ISO-8859-1' } },
- { L('MacRoman Encoding'), { utils.set_encoding, 'MacRoman' } },
- { L('UTF-16 Encoding'), { utils.set_encoding, 'UTF-16LE' } },
+ { title = _L['Encoding'],
+ { _L['UTF-8 Encoding'], { utils.set_encoding, 'UTF-8' } },
+ { _L['ASCII Encoding'], { utils.set_encoding, 'ASCII' } },
+ { _L['ISO-8859-1 Encoding'], { utils.set_encoding, 'ISO-8859-1' } },
+ { _L['MacRoman Encoding'], { utils.set_encoding, 'MacRoman' } },
+ { _L['UTF-16 Encoding'], { utils.set_encoding, 'UTF-16LE' } },
},
SEPARATOR,
- { L('Select Lexer...'), m_textadept.mime_types.select_lexer },
- { L('Refresh Syntax Highlighting'), { _buffer.colourise, _buffer, 0, -1 } },
+ { _L['Select Lexer...'], m_textadept.mime_types.select_lexer },
+ { _L['Refresh Syntax Highlighting'],
+ { _buffer.colourise, _buffer, 0, -1 } },
},
- { title = L('View'),
- { L('Next View'), { gui.goto_view, 1, true } },
- { L('Previous View'), { gui.goto_view, -1, true } },
+ { title = _L['View'],
+ { _L['Next View'], { gui.goto_view, 1, true } },
+ { _L['Previous View'], { gui.goto_view, -1, true } },
SEPARATOR,
- { L('Split View Horizontal'), { _view.split, _view } },
- { L('Split View Vertical'), { _view.split, _view, true } },
- { L('Unsplit View'), { _view.unsplit, _view } },
- { L('Unsplit All Views'), utils.unsplit_all },
- { L('Grow View'), { utils.grow, 10 } },
- { L('Shrink View'), { utils.shrink, 10 } },
+ { _L['Split View Horizontal'], { _view.split, _view } },
+ { _L['Split View Vertical'], { _view.split, _view, true } },
+ { _L['Unsplit View'], { _view.unsplit, _view } },
+ { _L['Unsplit All Views'], utils.unsplit_all },
+ { _L['Grow View'], { utils.grow, 10 } },
+ { _L['Shrink View'], { utils.shrink, 10 } },
SEPARATOR,
- { L('Toggle Current Fold'), utils.toggle_current_fold },
+ { _L['Toggle Current Fold'], utils.toggle_current_fold },
SEPARATOR,
- { L('Toggle View EOL'), { utils.toggle_property, 'view_eol' } },
- { L('Toggle Wrap Mode'), { utils.toggle_property, 'wrap_mode' } },
- { L('Toggle Show Indent Guides'),
+ { _L['Toggle View EOL'], { utils.toggle_property, 'view_eol' } },
+ { _L['Toggle Wrap Mode'], { utils.toggle_property, 'wrap_mode' } },
+ { _L['Toggle Show Indent Guides'],
{ utils.toggle_property, 'indentation_guides' } },
- { L('Toggle View Whitespace'), { utils.toggle_property, 'view_ws' } },
- { L('Toggle Virtual Space'),
+ { _L['Toggle View Whitespace'], { utils.toggle_property, 'view_ws' } },
+ { _L['Toggle Virtual Space'],
{ utils.toggle_property, 'virtual_space_options',
c.SCVS_USERACCESSIBLE } },
SEPARATOR,
- { L('Zoom In'), _buffer.zoom_in },
- { L('Zoom Out'), _buffer.zoom_out },
- { L('Reset Zoom'), utils.reset_zoom },
+ { _L['Zoom In'], _buffer.zoom_in },
+ { _L['Zoom Out'], _buffer.zoom_out },
+ { _L['Reset Zoom'], utils.reset_zoom },
SEPARATOR,
- { L('Select Theme...'), gui.select_theme },
+ { _L['Select Theme...'], gui.select_theme },
},
- { title = L('Help'),
- { L('Show Manual'),
+ { title = _L['Help'],
+ { _L['Show Manual'],
{ utils.open_webpage, _HOME..'/doc/manual/1_Introduction.html' } },
- { L('Show LuaDoc'), { utils.open_webpage, _HOME..'/doc/index.html' } },
+ { _L['Show LuaDoc'], { utils.open_webpage, _HOME..'/doc/index.html' } },
SEPARATOR,
- { L('gtk-about'),
+ { _L['gtk-about'],
{ gui.dialog, 'ok-msgbox', '--title', 'Textadept', '--informative-text',
_RELEASE, '--no-cancel' } },
},
@@ -224,15 +225,15 @@ M.menubar = {
-- @class table
-- @name context_menu
M.context_menu = {
- { L('gtk-undo'), _buffer.undo },
- { L('gtk-redo'), _buffer.redo },
+ { _L['gtk-undo'], _buffer.undo },
+ { _L['gtk-redo'], _buffer.redo },
SEPARATOR,
- { L('gtk-cut'), _buffer.cut },
- { L('gtk-copy'), _buffer.copy },
- { L('gtk-paste'), _buffer.paste },
- { L('gtk-delete'), _buffer.clear },
+ { _L['gtk-cut'], _buffer.cut },
+ { _L['gtk-copy'], _buffer.copy },
+ { _L['gtk-paste'], _buffer.paste },
+ { _L['gtk-delete'], _buffer.clear },
SEPARATOR,
- { L('gtk-select-all'), _buffer.select_all }
+ { _L['gtk-select-all'], _buffer.select_all }
}
local key_shortcuts = {}
@@ -324,12 +325,12 @@ local function build_command_tables(menu, title, items, commands)
end
end
-local columns = { L('Command'), L('Key Command') }
+local columns = { _L['Command'], _L['Key Command'] }
---
-- Prompts the user with a filteredlist to run menu commands.
-- @name select_command
function M.select_command()
- local i = gui.filteredlist(L('Run Command'), columns, items, true)
+ local i = gui.filteredlist(_L['Run Command'], columns, items, true)
if i then keys.run_command(commands[i + 1], type(commands[i + 1])) end
end
@@ -347,7 +348,7 @@ events.connect(events.MENU_CLICKED, function(menu_id)
local actions = menu_id < 1000 and menu_actions or contextmenu_actions
local action = actions[menu_id < 1000 and menu_id or menu_id - 1000]
if type(action) ~= 'function' and type(action) ~= 'table' then
- error(L('Unknown command:')..' '..tostring(action))
+ error(_L['Unknown command:']..' '..tostring(action))
end
keys.run_command(action, type(action))
end)