Command window - more flexibility?

Posted by Worstje on Wed 26 Nov 2008 11:00 PM — 11 posts, 26,981 views.

Netherlands #0
I'm working on a little plugin (which I hope to share here once done), and running into a few minor problems.

1) I cannot set the position of the cursor, nor select a part of the text.
2) It is hard to track changes as stuff is being edited. Something akin to the OnWorldOutputResized (called OnPluginCommandChanged or something) would be really sweet. I know you can check/prevent stuff after ENTER is pressed with another callback, but that's a very annoying method to use. I could also run a timer that updates every second, but I'm always unhappy with timers - they both need to be turned on and they will also always lag behind a little which I found in the past annoys me with 'live' previews.

Basically, I am making a sort-of squiggly-line preview indicator for when I'm writing paragraphs of text. With the intention of using Ctrl+#n# to jump to the #n#th word that had an incorrect spelling and have it selected right away. On top of that, it would also show stuff with colorcodes and such interpreted properly, since I keep messing those up from time to time.

Edit: I know there is the standard Ctrl+J spellcheck which can pretty much do what I want. It just doesn't work well with my workflow and my own wish to literally preview what I'm writing. :)
Amended on Wed 26 Nov 2008 11:04 PM by Worstje
Netherlands #1
I figured I'd use a screenshot to bump this feature request up a bit. *eyeshift* It still has a lot of little issues I need to resolve (spellcheck hitting parts I don't want it to hit like the WHOMEVER in the screenshot), but hopefully the usefulness of the requested features mentioned in the post above becomes a bit clearer.

http://qs.merseine.nu/images/previewer1.png
Amended on Fri 28 Nov 2008 12:34 AM by Worstje
Australia Forum Administrator #2
I don't see any objection to adding this.
Netherlands #3
You, kind sir, are awesome! :D

Edit: on that note, if there's any features said Previewer plugin could use that I haven't thought of yet, please drop me a message and I'll try to put it in. I might as well make it as useful as humanly possible. :)
Amended on Fri 28 Nov 2008 02:10 PM by Worstje
Australia Forum Administrator #4
Script function SetCommandSelection added to version 4.38.
Australia Forum Administrator #5
Plugin callback OnPluginCommandChanged added to version 4.38. This lets you know when the command window has changed.

Example plugin:



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

<muclient>
<plugin
   name="Command_Changed_Test"
   author="Nick Gammon"
   id="9c7ead5da253409e7a033b32"
   language="Lua"
   purpose="tests the OnPluginCommandChanged callback"
   date_written="2009-02-14 15:00"
   requires="4.38"
   version="1.0"
   >

</plugin>

<!--  Script  -->
<script>
<![CDATA[

function OnPluginCommandChanged ()
  print ("command now: '" .. GetCommand () .. "'")
end -- function

]]>
</script>
</muclient>


Amended on Sat 14 Feb 2009 03:03 AM by Nick Gammon
Netherlands #6
*goes to build a shrine in the basement dedicated to MUSHclient!*

I'll go find some time and work on this plugin again to finish up the rough edges I left for when these features were added. :) Thanks, Nick!
Netherlands #7
A little 'bug' report of sorts that I'd love to see fixed if possible...

If you have a lot of text typed that does not fit in the command window, and you use SetCommandSelection(), the text is selected but out of sight. It would be nice is the visual bit of the edit box also scrolled along so I can see what I selected. Of course, once you go typing it scrolls itself up, but I found it works on my nerves enough to mention it here. :)

Another thing that I noticed with regards to the command window... resizing a world window sets the size of the command window to the height that it would have without auto-sizing on, rather than the height the edit box had prior to that. Nothing that bugs me in this case, but I guess it would be unintentional behaviour. :)
Australia Forum Administrator #8
Quote:

It would be nice is the visual bit of the edit box also scrolled along so I can see what I selected.


I intended to do that, this was the code:


pmyView->GetEditCtrl().SetSel(First - 1, Last, TRUE);


The last argument was supposed to be "should I scroll the selection into view?".

However when I read the documentation more closely:


bNoScroll

Indicates whether the caret should be scrolled into view. If FALSE, the caret is scrolled into view. If TRUE, the caret is not scrolled into view.


So I had it backwards. I have changed it to FALSE for 4.40, which will scroll it into view.

Netherlands #9
A little 'bug' report...

The new callback OnPluginCommandChanged does not get triggered when you send the command and it clears due to the setting 'Auto-repeat command' being turned off.

I can go implement a workaround with OnPluginCommandEntered, but I'm not sure what kind of side-effects that eventually has if people use it to change the contents of the command window too.
Amended on Fri 20 Feb 2009 11:34 AM by Worstje
Australia Forum Administrator #10
Hmm, various places where the command window was programmatically changed (ie. other than typing or pasting) were not triggering the "on change" message.

I have tried to find the other places and made them do it too. (eg. if you hit escape to clear the command window).