From c511448b28a5b5c1e60ab87518f65245d169ae5b Mon Sep 17 00:00:00 2001 From: mitchell <70453897+orbitalquark@users.noreply.github.com> Date: Sat, 17 Oct 2020 16:02:51 -0400 Subject: Added `textadept.run.set_arguments()`. This replaces custom code in *modules/textadept/menu.lua*. --- modules/textadept/menu.lua | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) (limited to 'modules/textadept/menu.lua') diff --git a/modules/textadept/menu.lua b/modules/textadept/menu.lua index 1c7aa4b1..6f59b7ff 100644 --- a/modules/textadept/menu.lua +++ b/modules/textadept/menu.lua @@ -172,33 +172,7 @@ local default_menubar = { SEPARATOR, {_L['Run'], textadept.run.run}, {_L['Compile'], textadept.run.compile}, - {_L['Set Arguments...'], function() - if not buffer.filename then return end - local run_commands = textadept.run.run_commands - local compile_commands = textadept.run.compile_commands - local base_commands, utf8_args = {}, {} - for i, commands in ipairs{run_commands, compile_commands} do - -- Compare the base run/compile command with the one for the current - -- file. The difference is any additional arguments set previously. - base_commands[i] = commands[buffer.filename:match('[^.]+$')] or - commands[buffer:get_lexer()] or '' - local current_command = commands[buffer.filename] or '' - local args = current_command:sub(#base_commands[i] + 2) - utf8_args[i] = args:iconv('UTF-8', _CHARSET) - end - local button, utf8_args = ui.dialogs.inputbox{ - title = _L['Set Arguments...']:gsub('_', ''), informative_text = { - _L['Command line arguments'], _L['For Run:'], _L['For Compile:'] - }, text = utf8_args, width = not CURSES and 400 or nil - } - if button ~= 1 then return end - for i, commands in ipairs{run_commands, compile_commands} do - -- Add the additional arguments to the base run/compile command and set - -- the new command to be the one used for the current file. - commands[buffer.filename] = string.format('%s %s', base_commands[i], - utf8_args[i]:iconv(_CHARSET, 'UTF-8')) - end - end}, + {_L['Set Arguments...'], textadept.run.set_arguments}, {_L['Build'], textadept.run.build}, {_L['Stop'], textadept.run.stop}, {_L['Next Error'], function() textadept.run.goto_error(true) end}, -- cgit v1.2.3