Is DoCommand() the proper way to call copy?

Posted by Kahenraz on Fri 26 Apr 2019 10:35 AM — 5 posts, 20,071 views.

#0
Is this the proper way to call "copy" or is there a dedicated command for this?
#1
Can we get a GetCommandSelection() for synchronous copying of a selection within the command window?
Australia Forum Administrator #2
See GetInfo selectors 236 and 237.

Template:function=GetInfo
GetInfo

The documentation for the GetInfo script function is available online. It is also in the MUSHclient help file.

Australia Forum Administrator #3
Example:


<aliases>
  <alias
   match="copy"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

cmd = GetCommand()
st = GetInfo (236)  -- start column
en = GetInfo (237)  -- end column

if en == 0 then
  selection = cmd  -- no selection, take all
else
  selection = cmd:sub (st, en)  -- get selection
end

print ("Selection is", selection)

SetClipboard(selection)  -- put on clipboard

</send>
  </alias>
</aliases>


Template:pasting
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


This alias will copy the selection to the clipboard. Of course, if you run it as an alias the clipboard will then contain "copy". You can however make a macro which has "copy" in it, then you can press (say) F5 when you have text selected in the command window and the selected text will be copied.
Amended on Sun 28 Apr 2019 03:06 AM by Nick Gammon
#4
That worked great! Thank you.