Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Config_Option_Changer plugin to the distribution
- Loading branch information
1 parent
9e3a4b5
commit d1f4b6e
Showing
2 changed files
with
223 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
<?xml version="1.0" encoding="iso-8859-1"?> | ||
<!DOCTYPE muclient> | ||
<!-- Saved on Monday, August 09, 2010, 10:29 AM --> | ||
<!-- MuClient version 4.56 --> | ||
|
||
<!-- Plugin "Config_Option_Changer" generated by Plugin Wizard --> | ||
|
||
<muclient> | ||
<plugin | ||
name="Config_Option_Changer" | ||
author="Nick Gammon" | ||
id="edb75e5e80221bfb1a83a234" | ||
language="Lua" | ||
purpose="Changes options not available in GUI configuration" | ||
date_written="2010-08-09 10:28:14" | ||
requires="4.50" | ||
version="1.0" | ||
> | ||
<description trim="y"> | ||
<![CDATA[ | ||
Type 'config_options' to see dialog of options to change. | ||
]]> | ||
</description> | ||
|
||
</plugin> | ||
|
||
|
||
<!-- Aliases --> | ||
|
||
<aliases> | ||
<alias | ||
script="config_options" | ||
match="config_options" | ||
enabled="y" | ||
sequence="100" | ||
> | ||
</alias> | ||
</aliases> | ||
|
||
<!-- Script --> | ||
|
||
|
||
<script> | ||
<![CDATA[ | ||
-- See: http://www.gammon.com.au/forum/?id=10430 | ||
-- alpha options they can change | ||
alpha_options = { | ||
editor_window_name = { desc = 'Name of external editor window' }, | ||
script_editor_argument = { desc = 'External editor argument' }, | ||
} -- end alpha_options | ||
-- boolean options they can change | ||
boolean_options = { | ||
auto_resize_command_window = { desc = 'Auto-resize command window?' }, | ||
default_alias_regexp = { desc = 'New aliases: default to regular expression?' }, | ||
default_alias_expand_variables = { desc = 'New aliases: default to expand variables?' }, | ||
default_alias_keep_evaluating = { desc = 'New aliases: default to keep evaluating?' }, | ||
default_alias_ignore_case = { desc = 'New aliases: default to ignore case?' }, | ||
default_trigger_regexp = { desc = 'New triggers: default to regular expression?' }, | ||
default_trigger_expand_variables = { desc = 'New triggers: default to expand variables?' }, | ||
default_trigger_keep_evaluating = { desc = 'New triggers: default to keep evaluating?' }, | ||
default_trigger_ignore_case = { desc = 'New triggers: default to ignore case?' }, | ||
do_not_add_macros_to_command_history = { desc = 'Do not add macros to command history?' }, | ||
do_not_show_outstanding_lines = { desc = 'Do not show outstanding lines count?' }, | ||
do_not_translate_iac_to_iac_iac = { desc = 'Do not translate IAC to IAC IAC?' }, | ||
play_sounds_in_background = { desc = 'Play sounds in background?' }, | ||
send_keep_alives = { desc = 'Send keep-alives?' }, | ||
} -- end boolean_options | ||
-- numeric options they can change | ||
numeric_options = { | ||
auto_resize_minimum_lines = { desc = 'Auto-resize: minimum lines', min = 1, max = 100 }, | ||
auto_resize_maximum_lines = { desc = 'Auto-resize: maximum lines', min = 1, max = 100 }, | ||
default_alias_send_to = { desc = 'New aliases: Default send-to location', min = 0, max = 14 }, | ||
default_alias_sequence = { desc = 'New aliases: Default sequence', min = 0, max = 10000 }, | ||
default_timer_send_to = { desc = 'New timers: Default send-to location', min = 0, max = 14 }, | ||
default_trigger_send_to = { desc = 'New triggers: Default send-to location', min = 0, max = 14 }, | ||
default_trigger_sequence = { desc = 'New triggers: Default sequence', min = 0, max = 10000 }, | ||
} -- end numeric_options | ||
function edit_boolean_option (name) | ||
local val = GetOption (name) | ||
local info = boolean_options [name] | ||
local default = 1 -- default to "Yes" button | ||
-- if option not set, default to "No" button | ||
if val == 0 then | ||
default = 2 | ||
end -- if | ||
-- what do they *really* want? | ||
local response = utils.msgbox (info.desc, "Change option", "yesnocancel", "?", default ) | ||
-- notify if switched | ||
if response == "yes" and val == 0 then | ||
SetOption (name, 1) | ||
ColourNote ("cyan", "", "Option " .. name .. " changed to: Yes") | ||
elseif response == "no" and val == 1 then | ||
SetOption (name, 0) | ||
ColourNote ("cyan", "", "Option " .. name .. " changed to: No") | ||
end -- if | ||
end -- edit_boolean_option | ||
function edit_alpha_option (name) | ||
local val = GetAlphaOption (name) | ||
local info = alpha_options [name] | ||
local response = utils.inputbox (info.desc, "Change option", val, "Courier", 9) | ||
-- if not cancelled, and value change, notify them | ||
if response and response ~= val then | ||
SetAlphaOption (name, response) | ||
ColourNote ("cyan", "", string.format ("Option %s changed from '%s' to '%s'", name, val, response)) | ||
end -- if | ||
end -- edit_alpha_option | ||
function edit_numeric_option (name) | ||
local val = tonumber (GetOption (name)) | ||
local info = numeric_options [name] | ||
local response = utils.inputbox ( | ||
string.format ("%s\r\n\r\nRange: %i to %i", info.desc, info.min, info.max), | ||
"Change option", val, "Courier", 9) | ||
if not response then | ||
return | ||
end -- cancelled | ||
-- check numeric | ||
n = tonumber (response) | ||
if not n then | ||
utils.msgbox ("You must enter a number", | ||
"Incorrect input", "ok", "!", 1) | ||
return | ||
end -- if | ||
-- check in range | ||
if n < info.min or n > info.max then | ||
utils.msgbox (info.desc .. " must be in range " .. | ||
info.min .. " to " .. info.max, | ||
"Incorrect input", "ok", "!", 1) | ||
return | ||
end -- if | ||
-- notify them if value changed | ||
if n ~= val then | ||
SetOption (name, n) | ||
ColourNote ("cyan", "", string.format ("Option %s changed from %i to %i", name, val, n)) | ||
end -- if | ||
end -- edit_numeric_option | ||
function config_options (name, line, wildcards) | ||
repeat | ||
local choices = {} | ||
-- build table of choices, with existing values | ||
-- alpha | ||
for k, v in pairs (alpha_options) do | ||
local val = GetAlphaOption (k) | ||
if val then | ||
choices [k] = string.format ("%s (%s)", v.desc, val) | ||
end -- if exists | ||
end -- for alpha_options | ||
-- boolean | ||
for k, v in pairs (boolean_options) do | ||
local val = GetOption (k) | ||
local yes_no = "Yes" | ||
if val == 0 then | ||
yes_no = "No" | ||
end -- if | ||
if val then | ||
choices [k] = string.format ("%s (%s)", v.desc, yes_no) | ||
end -- if exists | ||
end -- for boolean_options | ||
-- numeric | ||
for k, v in pairs (numeric_options) do | ||
local val = GetOption (k) | ||
if val then | ||
choices [k] = string.format ("%s (%i)", v.desc, val) | ||
end -- if exists | ||
end -- for numeric_options | ||
-- choose one ... | ||
local result = utils.listbox ( | ||
"Choose an option to edit.\r\n\r\nClick Cancel when done (any changes will be retained).", | ||
"Options", choices) | ||
-- if not cancelled, go to appropriate handler | ||
if result then | ||
if alpha_options [result] then | ||
edit_alpha_option (result) | ||
elseif boolean_options [result] then | ||
edit_boolean_option (result) | ||
elseif numeric_options [result] then | ||
edit_numeric_option (result) | ||
end -- if | ||
end -- if they chose something | ||
until not result -- loop until dialog cancelled | ||
end -- function config_options | ||
ColourNote ("cyan", "", "Type 'config_options' to view options dialog.") | ||
]]> | ||
</script> | ||
|
||
|
||
</muclient> |