Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Plugins ➜ Plugin to change non-GUI options

Plugin to change non-GUI options

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Mon 09 Aug 2010 12:37 AM (UTC)

Amended on Tue 10 Aug 2010 12:18 AM (UTC) by Nick Gammon

Message
There are various world options in MUSHclient these days that are not supported directly in the GUI interface.

They are documented here:

http://www.gammon.com.au/forum/?id=10430

To make it easier to view and change these options the plugin below has been developed. This lets you quickly see all of the options in a nice listbox, and double-click any of them to edit its value.

Template:saveplugin=Config_Option_Changer To save and install the Config_Option_Changer plugin do this:
  1. Copy between the lines below (to the Clipboard)
  2. Open a text editor (such as Notepad) and paste the plugin into it
  3. Save to disk on your PC, preferably in your plugins directory, as Config_Option_Changer.xml
  4. Go to the MUSHclient File menu -> Plugins
  5. Click "Add"
  6. Choose the file Config_Option_Changer.xml (which you just saved in step 3) as a plugin
  7. Click "Close"



<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<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"
   date_modified="2010-08-10 09:50"
   requires="4.50"
   version="2.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 = 'Add macros to command history?' , invert = true },
  do_not_show_outstanding_lines         = { desc = 'Show outstanding lines count?' , invert = true  },
  do_not_translate_iac_to_iac_iac       = { desc = 'Translate IAC to IAC IAC?' , invert = true  },
  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 and not info.invert) or
     (val == 1 and info.invert) then
    default = 2  -- default is "No" button
  end -- if

  -- what do they *really* want?
  local response = utils.msgbox (info.desc, "Change option", "yesnocancel", "?", default )
  
  -- if cancelled dialog, just return
  if response == "cancel" then
    return
  end -- if cancelled

  -- if inverted question, we invert the response meaning  
  local newval = 0
  
  if info.invert then
    if response == "no" then
      newval = 1
    end -- if
  else
    if response == "yes" then
      newval = 1
    end -- if
  end -- if
  
  -- notify if switched
  if val ~= newval then
    SetOption (name, newval)
    ColourNote ("cyan", "", "Option '" .. info.desc .. "' changed to: " .. response)
  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 cancelled dialog, just return
  if not response then
    return
  end -- cancelled
  
  -- if value changed, notify them
  if response ~= val then
    SetAlphaOption (name, response)
    ColourNote ("cyan", "", string.format ("Option '%s' changed from '%s' to '%s'", info.desc, 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 cancelled dialog, just return
  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", info.desc, 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 and not v.invert) or
         (val == 1 and v.invert) 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>


Example of it in operation:






This plugin will be distributed as part of the installation for version 4.57 onwards.

[EDIT] Amended 10 August 2010 to make the "inverse" options easier to use. Now, instead of an option "Do not show outstanding lines count?" it has "Show outstanding lines count?". This saves having a double-negative (it is confusing to have a "no" answer to a "do not do xxx" option).

Internally the plugin reverses the sense of the question, so the underlying option is set correctly.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


6,832 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.