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.
Entire forum
➜ MUSHclient
➜ Bug reports
➜ Copying output using keyboard shortcut (Ctrl+C) while all keys to command box on
Copying output using keyboard shortcut (Ctrl+C) while all keys to command box on
|
Posting of new messages is disabled at present.
Refresh page
Pages: 1
2 3
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #15 on Thu 02 Aug 2007 05:24 PM (UTC) Amended on Thu 02 Aug 2007 05:26 PM (UTC) by Nick Gammon
|
Message
| I can't reproduce that. It seems to work every time for me. You are using Linux aren't you? Perhaps the quirk is in there?
Try making a test case where you do SetClipboard twice in a row, and check the clipboard after each time. Maybe Wine is not handling SetClipboard correctly. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Shaun Biggs
USA (644 posts) Bio
|
Date
| Reply #16 on Thu 02 Aug 2007 09:56 PM (UTC) |
Message
| SetClipboard works perfectly fine. I've used it in many other scripts before, and I just tested it manually. Seems to be in working order. I'll test it out on my old laptop to see if I can get it working in a win98 install, but if it's just on my computer, I guess I can live with it. |
It is much easier to fight for one's ideals than to live up to them. | Top |
|
Posted by
| Worstje
Netherlands (899 posts) Bio
|
Date
| Reply #17 on Fri 03 Aug 2007 12:26 AM (UTC) Amended on Fri 03 Aug 2007 12:31 AM (UTC) by Worstje
|
Message
| It's not Linux. I'm suffering from the 'double Ctrl+C' problem too, and I am using WXP.
Funnily enough, it only happens when the focus box is -NOT- in the command box, which in turn only becomes an issue if 'All typing goes to command box' is turned OFF.
After I turned it on, it started working properly.
On a side note though... it is quite annoying that after using this Ctrl+C, the selection immediately disappears. I am not sure what causes it, but personally I think that somehow the alias I use with Accelerator is what indirectly causes the selection to be lost. I seem to notice some 'flickering' on the last line of the output area.
On the other hand, I could get used to it. Maybe. ^_^
Thanks, Shaun Biggs, for the nice script! I changed the "\n" to "\r\n" though, that plays a bit nicer in Windows. | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #18 on Fri 03 Aug 2007 01:20 AM (UTC) |
Message
| If you aren't forcing input to the command window, you don't need the script do you? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Worstje
Netherlands (899 posts) Bio
|
Date
| Reply #19 on Fri 03 Aug 2007 01:43 AM (UTC) |
Message
| I don't. I found out halfway my post I forgot to set the setting before loading the script. I think Shaun Biggs forgot just like I did. :) | Top |
|
Posted by
| Shaun Biggs
USA (644 posts) Bio
|
Date
| Reply #20 on Fri 03 Aug 2007 04:44 AM (UTC) |
Message
| I just tried it with typing sent to output only toggled on and off. You're right Worstje, the function only works if it's needed, and it screws up the normal copy when it's not needed. Probably why I missed it before.
Is there anything in GetInfo or a similar function to tell if output is going only to the command window? That would fix the script with a simple or in the first if statement.
if GetInfo( foo ) == false or line1 == 0 then
DoCommand( "copy" )
else
|
It is much easier to fight for one's ideals than to live up to them. | Top |
|
Posted by
| Worstje
Netherlands (899 posts) Bio
|
Date
| Reply #21 on Wed 08 Aug 2007 03:36 AM (UTC) |
Message
| I had some kind of request for a feature until I remembered GetLineInfo(), which was precisely what I needed. (It's strange how you can't ever figure out what name to give a certain feature until you are ready to click 'Save' on this forum...)
Anyhow, I threw the stuff into a plugin and adjusted it to suit my needs. Use it as you like! (And thanks again, Shaun Biggs!)
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on vrijdag, augustus 03, 2007, 2:06 -->
<!-- MuClient version 4.14 -->
<!-- Plugin "CopyScript" generated by Plugin Wizard -->
<muclient>
<plugin
name="CopyScript"
author="Mygale"
id="eebb80f374370f77176cb2ed"
language="Lua"
purpose="Allows you to use CTRL+C for the output if 'All typing goes to command window' is turned on."
save_state="n"
date_written="2007-08-03 02:04:12"
requires="4.00"
version="1.0"
>
</plugin>
<aliases>
<alias
match="^CopyScript:Copy$"
enabled="y"
regexp="y"
omit_from_output="y"
sequence="100"
script="CopyScript"
>
</alias>
</aliases>
<!-- Script -->
<script>
<![CDATA[
-- Thank you, Shaun Biggs, for taking your time to write the CopyScript
-- (formerly Copy2) function below. It was slightly altered by me to suit
-- my usage (wordwrapped lines and no \r\n at start of selection).
Accelerator ("Ctrl+C", "CopyScript:Copy")
function CopyScript(name, line, wildcs)
local line1, line2 = GetSelectionStartLine(), GetSelectionEndLine()
local col1, col2 = GetSelectionStartColumn(), GetSelectionEndColumn()
if line1 == 0 then
DoCommand("copy")
else
local copystring = ""
while line1 <= line2 do
if line1 < line2 then
copystring = copystring..string.sub(GetLineInfo(line1).text, col1)
col1 = 1
else
copystring = copystring..string.sub(GetLineInfo(line1).text, col1, col2-1)
end
-- Is this a new line or merely the continuation of a paragraph?
if (world.GetLineInfo(line1, 3) == true) then
copystring = copystring .. "\r\n"
end
line1 = line1 + 1
end
if (string.sub(copystring, 1, 2) == "\r\n") then
-- Get rid of a spurious extra new line at the start.
copystring = string.sub(copystring, 3, -1)
end
SetClipboard(copystring)
end
end -- function CopyScript
]]>
</script>
</muclient>
| Top |
|
Posted by
| Shaun Biggs
USA (644 posts) Bio
|
Date
| Reply #22 on Wed 08 Aug 2007 04:44 AM (UTC) |
Message
| Heh, didn't even notice the weird issue with wrapped lines. Good bug catch and a good solution However, this is where I but that bit of code:
while line1 <= line2 do
if line1 < line2 then
copystring = copystring..string.sub(GetLineInfo(line1).text, col1)
if GetLineInfo(line1, 3) == true then
copystring = copystring.."\r\n"
end
col1 = 1
else
copystring = copystring..string.sub(GetLineInfo(line1).text, col1, col2-1)
end
line1 = line1 + 1
end
This prevents an extra "\r\n" from being added if you just highlight part of a line that's a continuation of the previous line.
ex:
CLAN: Trumpets sound in the Emerald stronghold as Knight Balaam returns from
afar.
capturing the underlined word above winds up with the "afar\r\n" in the clipboard with your version. Getting rid of a linefeed at the beginning would drive me batty if I were to actually want that there (copying a blank line for some reason), but I could see why many people would want that in as well. |
It is much easier to fight for one's ideals than to live up to them. | Top |
|
Posted by
| Shaun Biggs
USA (644 posts) Bio
|
Date
| Reply #23 on Wed 08 Aug 2007 04:55 AM (UTC) |
Message
| And yet another fun fix, since not everyone has "/" set for the script prefix.
Accelerator ("Ctrl+C", GetAlphaOption("script_prefix").."Copy2()")
I still can't find anything under GetInfo, GetOption, or GetAlphaOption to check to see if all typing goes to the command window. I can't seem to find any other global options listed where scripting languages can check the values. Perhaps a GetGlobalOption function would help out with that issue. SetGlobalOption could be kind of annoying if two scripts for different worlds start to compete for who has control over the whole client, but there's no harm in checking what's been selected by the user. |
It is much easier to fight for one's ideals than to live up to them. | Top |
|
Posted by
| Worstje
Netherlands (899 posts) Bio
|
Date
| Reply #24 on Wed 08 Aug 2007 02:31 PM (UTC) Amended on Wed 08 Aug 2007 02:32 PM (UTC) by Worstje
|
Message
| Oooh, good catch on your turn with the spurious \r\n issue. I hadn't noticed that. The thing with the script accelerator I already took care of; hence the 'CopyScript:Copy' alias. That avoids the issue of what the seperator is all together.
Last of all, the reason I kill any leading new-lines is pretty simple. Take a look at the following 'example'
Courtyard of Valor. X
A sturdy iron forge stands here, cold and dark. Clutching a
golden blade, a plated arm rises up from a massive square
slab of iron as homage to the God of Valor. A solemn looking
chaplain rests the base of his tower shield on the ground
and hefts his mace. Tossing her august mane, a sprightly
white mare stands here. X
You see exits leading north(closed), northeast(open),
east, southeast and west.
Suppose I want to drag this room description. Most of the time, I won't bother with going precisely to the start of the line at 'A sturdy iron force'. Rather, I'll click at the lower X, drag up and stop at the top X. Without the fix, this means I get stuck with an extra newline at the start of my copied paragraph (which always annoyed me with the built-in copying mechanism). | Top |
|
Posted by
| Shaun Biggs
USA (644 posts) Bio
|
Date
| Reply #25 on Wed 08 Aug 2007 03:11 PM (UTC) Amended on Wed 08 Aug 2007 03:16 PM (UTC) by Shaun Biggs
|
Message
| The alias does get around people not having set their script prefix yet. I'd just rather have a way for an Accelerator to call a script directly. Possibly have the same send to list as an alias.
And for the extra new line, as I said, I could see why many people would want it. I just expect the copy function to grab exactly what I highlighted. If I released the plugin, I'd probably have a flag that can be set to give people the option erase that extra newline or not. A good example of this is a script that I have to condense the output of dropping multiple items and putting them in or taking them out of a bag. A few people wanted a blank line after the output script to separate it and make it easier to read, but I like really condensed output. So I made the extra line an option to make everyone happy. |
It is much easier to fight for one's ideals than to live up to them. | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #26 on Wed 08 Aug 2007 11:49 PM (UTC) |
Message
|
Quote:
I can't seem to find any other global options listed where scripting languages can check the values. Perhaps a GetGlobalOption function would help out with that issue.
Added GetGlobalOption to version 4.18. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #27 on Sat 16 Feb 2008 10:17 PM (UTC) Amended on Sun 17 Feb 2008 02:40 AM (UTC) by Nick Gammon
|
Message
| I have played with this a bit as the problem with Ctrl+C was beginning to get on my nerves. There was a problem with the earlier version, that if you copied a single letter on a line that ended with a linefeed, the linefeed ended up on the clipboard. Here is my amended version:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on vrijdag, augustus 03, 2007, 2:06 -->
<!-- MuClient version 4.14 -->
<!-- Plugin "CopyScript" generated by Plugin Wizard -->
<!-- Amended slightly by Nick Gammon, from Worstje's version, on 17 Feb 2008 -->
<muclient>
<plugin
name="Copy_Output"
author="Worstje"
id="a0df42a8e796d974f4364245"
language="Lua"
purpose="Allows you to use CTRL+C for the output window if 'All typing goes to command window' is turned on."
save_state="n"
date_written="2007-08-03 02:04:12"
requires="4.00"
version="1.0"
>
</plugin>
<aliases>
<alias
match="^Copy_Output:Copy:1bb75c016bc3e2b9d4c292db$"
enabled="y"
regexp="y"
omit_from_output="y"
sequence="100"
script="CopyScript"
>
</alias>
</aliases>
<!-- Script -->
<script>
<![CDATA[
-- Thank you, Shaun Biggs, for taking your time to write the CopyScript
-- (formerly Copy2) function below. It was slightly altered by me to suit
-- my usage (wordwrapped lines and no \r\n at start of selection).
-- See forum: http://www.gammon.com.au/forum/bbshowpost.php?id=8052
-- some long alias that no-one will ever want to type
Accelerator ("Ctrl+C", "Copy_Output:Copy:1bb75c016bc3e2b9d4c292db")
function CopyScript(name, line, wildcs)
-- find selection in output window, if any
local first_line, last_line = GetSelectionStartLine(),
math.min (GetSelectionEndLine(), GetLinesInBufferCount ())
local first_column, last_column = GetSelectionStartColumn(), GetSelectionEndColumn()
-- nothing selected, do normal copy
if first_line <= 0 then
DoCommand("copy")
return
end -- if nothing to copy from output window
local copystring = ""
-- iterate to build up copy text
for line = first_line, last_line do
if line < last_line then
copystring = copystring .. GetLineInfo(line).text:sub (first_column) -- copy rest of line
first_column = 1
-- Is this a new line or merely the continuation of a paragraph?
if GetLineInfo (line, 3) then
copystring = copystring .. "\r\n"
end -- new line
else
copystring = copystring .. GetLineInfo(line).text:sub (first_column, last_column - 1)
end -- if
end -- for loop
-- Get rid of a spurious extra new line at the start.
if copystring:sub (1, 2) == "\r\n" then
copystring = copystring:sub (3)
end -- if newline at start
-- finally can set clipboard contents
SetClipboard(copystring)
end -- function CopyScript
]]>
</script>
</muclient>
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #28 on Sat 16 Feb 2008 10:28 PM (UTC) |
Message
| |
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #29 on Sun 17 Feb 2008 02:41 AM (UTC) |
Message
| Amended plugin to add:
math.min (GetSelectionEndLine(), GetLinesInBufferCount ())
It was failing if you did a "select all" because the selection end line was actually past the end of the buffer. |
- 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.
94,276 views.
This is page 2, subject is 3 pages long:
1
2 3
Posting of new messages is disabled at present.
Refresh page
top