Skip to content

Commit 9afdffb

Browse files
committed
Improved Config_Option_Changer plugin
1 parent d1f4b6e commit 9afdffb

File tree

1 file changed

+45
-24
lines changed

1 file changed

+45
-24
lines changed

plugins/Config_Option_Changer.xml

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<?xml version="1.0" encoding="iso-8859-1"?>
22
<!DOCTYPE muclient>
3-
<!-- Saved on Monday, August 09, 2010, 10:29 AM -->
4-
<!-- MuClient version 4.56 -->
5-
6-
<!-- Plugin "Config_Option_Changer" generated by Plugin Wizard -->
73

84
<muclient>
95
<plugin
@@ -13,8 +9,9 @@
139
language="Lua"
1410
purpose="Changes options not available in GUI configuration"
1511
date_written="2010-08-09 10:28:14"
12+
date_modified="2010-08-10 09:50"
1613
requires="4.50"
17-
version="1.0"
14+
version="2.0"
1815
>
1916
<description trim="y">
2017
<![CDATA[
@@ -63,9 +60,9 @@ boolean_options = {
6360
default_trigger_expand_variables = { desc = 'New triggers: default to expand variables?' },
6461
default_trigger_keep_evaluating = { desc = 'New triggers: default to keep evaluating?' },
6562
default_trigger_ignore_case = { desc = 'New triggers: default to ignore case?' },
66-
do_not_add_macros_to_command_history = { desc = 'Do not add macros to command history?' },
67-
do_not_show_outstanding_lines = { desc = 'Do not show outstanding lines count?' },
68-
do_not_translate_iac_to_iac_iac = { desc = 'Do not translate IAC to IAC IAC?' },
63+
do_not_add_macros_to_command_history = { desc = 'Add macros to command history?' , invert = true },
64+
do_not_show_outstanding_lines = { desc = 'Show outstanding lines count?' , invert = true },
65+
do_not_translate_iac_to_iac_iac = { desc = 'Translate IAC to IAC IAC?' , invert = true },
6966
play_sounds_in_background = { desc = 'Play sounds in background?' },
7067
send_keep_alives = { desc = 'Send keep-alives?' },
7168
} -- end boolean_options
@@ -85,24 +82,41 @@ numeric_options = {
8582
function edit_boolean_option (name)
8683
local val = GetOption (name)
8784
local info = boolean_options [name]
85+
8886
local default = 1 -- default to "Yes" button
8987
9088
-- if option not set, default to "No" button
91-
if val == 0 then
92-
default = 2
89+
if (val == 0 and not info.invert) or
90+
(val == 1 and info.invert) then
91+
default = 2 -- default is "No" button
9392
end -- if
9493
9594
-- what do they *really* want?
9695
local response = utils.msgbox (info.desc, "Change option", "yesnocancel", "?", default )
9796
97+
-- if cancelled dialog, just return
98+
if response == "cancel" then
99+
return
100+
end -- if cancelled
101+
102+
-- if inverted question, we invert the response meaning
103+
local newval = 0
104+
105+
if info.invert then
106+
if response == "no" then
107+
newval = 1
108+
end -- if
109+
else
110+
if response == "yes" then
111+
newval = 1
112+
end -- if
113+
end -- if
114+
98115
-- notify if switched
99-
if response == "yes" and val == 0 then
100-
SetOption (name, 1)
101-
ColourNote ("cyan", "", "Option " .. name .. " changed to: Yes")
102-
elseif response == "no" and val == 1 then
103-
SetOption (name, 0)
104-
ColourNote ("cyan", "", "Option " .. name .. " changed to: No")
105-
end -- if
116+
if val ~= newval then
117+
SetOption (name, newval)
118+
ColourNote ("cyan", "", "Option '" .. info.desc .. "' changed to: " .. response)
119+
end -- if
106120
107121
end -- edit_boolean_option
108122
@@ -112,10 +126,15 @@ function edit_alpha_option (name)
112126
113127
local response = utils.inputbox (info.desc, "Change option", val, "Courier", 9)
114128
115-
-- if not cancelled, and value change, notify them
116-
if response and response ~= val then
129+
-- if cancelled dialog, just return
130+
if not response then
131+
return
132+
end -- cancelled
133+
134+
-- if value changed, notify them
135+
if response ~= val then
117136
SetAlphaOption (name, response)
118-
ColourNote ("cyan", "", string.format ("Option %s changed from '%s' to '%s'", name, val, response))
137+
ColourNote ("cyan", "", string.format ("Option '%s' changed from '%s' to '%s'", info.desc, val, response))
119138
end -- if
120139
121140
end -- edit_alpha_option
@@ -127,11 +146,12 @@ function edit_numeric_option (name)
127146
local response = utils.inputbox (
128147
string.format ("%s\r\n\r\nRange: %i to %i", info.desc, info.min, info.max),
129148
"Change option", val, "Courier", 9)
130-
149+
150+
-- if cancelled dialog, just return
131151
if not response then
132152
return
133153
end -- cancelled
134-
154+
135155
-- check numeric
136156
n = tonumber (response)
137157
@@ -152,7 +172,7 @@ function edit_numeric_option (name)
152172
-- notify them if value changed
153173
if n ~= val then
154174
SetOption (name, n)
155-
ColourNote ("cyan", "", string.format ("Option %s changed from %i to %i", name, val, n))
175+
ColourNote ("cyan", "", string.format ("Option '%s' changed from %i to %i", info.desc, val, n))
156176
end -- if
157177
158178
end -- edit_numeric_option
@@ -176,7 +196,8 @@ function config_options (name, line, wildcards)
176196
for k, v in pairs (boolean_options) do
177197
local val = GetOption (k)
178198
local yes_no = "Yes"
179-
if val == 0 then
199+
if (val == 0 and not v.invert) or
200+
(val == 1 and v.invert) then
180201
yes_no = "No"
181202
end -- if
182203
if val then

0 commit comments

Comments
 (0)