Aborting command within OnPluginCommandEntered without clearing command window?

Posted by j0nas on Wed 12 Jul 2006 05:50 PM — 4 posts, 16,377 views.

#0
I'm trying to implement spellchecks for certain inputs only, like says, poses, <whatever>, but not anything else like movement-commands and such. Initially, I did that using Nick's OnPluginCommand-example, but it turns out I can't have the input parsed by my aliases and OnPluginCommand at the same time, so I promptly upgraded to 3.75 and started using OnPluginCommandEntered instead.

The problem I'm having now is, I can't find a way to abort the sending of the text without also wiping the input from the input-buffer permamently, no way to get it back. I'd like to be able to cancel the spellcheck to add/remove something, without having to rewrite the entire <whatever>.

Right now, I have this Lua stuffed into a plugin:


function OnPluginCommandEntered (sText)
  a, b, c = rex.new ("(?:say |:|spoof |ooc |page \w+|whisper \w+)(.+)"):exec (sText)

  if a == nil then
    return sText  -- not matched our regular expression
  end

  -- matched regular expression - check the command
  check = SpellCheckCommand (c [1], c [2])

  -- if check failed, cancel sending
  if check == 0 then
  	SelectCommand()
    PasteCommand(sText)
    return '\t'	-- cancelled, don't process
  end

  -- get the amended command, send that instead
  return GetCommand ()
end



Any suggestions?
Amended on Wed 12 Jul 2006 05:55 PM by j0nas
Australia Forum Administrator #1
Hmmm, I didn't think of that. :)

There is another bug too, it shouldn't clear the command window if "auto-repeat" is set.

Version 3.76 will offer a new option - if you return the \r character, the command will not be sent, but will be retained in the command window.
Australia Forum Administrator #2
In the meantime, this seemed to work OK:


  -- if check failed, cancel sending
  if check == 0 then
    DoAfterSpecial (0.1, string.format ("PasteCommand (%q)", sText), 12)
    return '\t'	-- cancelled, don't process
  end


This introduces a slight delay, which lets MUSHclient clear the command window, and then puts the command back, that should be a workaround for now.
Amended on Wed 12 Jul 2006 10:05 PM by Nick Gammon
#3
It does indeed, thank you!