Page 1 of 1
bug with copying text from start of folded text
Posted: Sun Dec 05, 2010 9:42 pm
by gwgs
This occurs in Zeus 3.97c. I'm using windows 7
Sample Text:
Code: Select all
function abc (def, ghi):
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
When folded:
select abc and copy to clipboard, when you paste you get a column of text from the folded block, eg
Not useful when all you want is the function name in this case.
Please fix.
Thanks in advance
Grant Smith
Posted: Sun Dec 05, 2010 11:12 pm
by jussij
Hi Grant,
I would argue that Zeus has worked exactly as designed
You have folded away
8 lines into 1 and then you copied
3 characters from the folded line.
The result of the copy is the 3 characters in selected range of all 8 lines get copied to the clipboard.
This is analogous to what would have happen if you had selected the entire line, in which case
all 8 lines get copied to the clipboard.
To me both these behaviors’ are consisted and to be expected for folded lines
Cheers Jussi
Posted: Sun Dec 05, 2010 11:48 pm
by gwgs
I can see your point of view. But I see it as an unexpected result.
When I try the same thing in the PythonWin editor all that is copied and pasted is the function name abc using the same example above. This is the result I expected. I have all the functions folded for readability, when i select a function name and copy it, I don't expect or want a column of text the width of the function name. Makes for unexpected results when you paste (what you expect) into a cmdline and get a potentially huge block of code pasted instead.
The workaround of opening the folded code, finding the start of the block and then selecting the word/function name you originally selected seems very cumbersome and slow.
Thanks
Grant Smith
Posted: Mon Dec 06, 2010 1:56 am
by jussij
The workaround of opening the folded code, finding the start of the block and then selecting the word/function name you originally selected seems very cumbersome and slow.
But if you actually wanted this current behaviour then the alternative would likewise be
cumbersome and slow since you would have to manually column mark all the lines of the folded area.
But in any case don’t forget Zeus is scriptable, so by righting a simple script it should be easy enough to make Zeus behave which ever way you like.
See below my first rough attempt at a Python script to do exactly what you describe. As a first attempt it is a bit rough around the edges and still needs to be debugged but it does indicate that a script solution is possible
Cheers Jussi
Code: Select all
import zeus
def key_macro():
FOLD_NONE = 0
# check if the current line is a fold point or if we have no markings
if zeus.get_line_folding() == FOLD_NONE or zeus.is_marked() == 0:
# leave it up to default behaviour
zeus.MarkCopyEx()
else:
# get the current mark range
top = zeus.get_marked_top()
bottom = zeus.get_marked_bottom()
# see if this is the 'single line' marked case
if bottom == top:
# copy the lines to the clipboard
zeus.MarkCopyEx()
# read back the lines from the clipboard
text = zeus.get_clipboard_text()
# break clipboard data into lines and throw away the line feeds
keepends = 0
results = text.splitlines(keepends)
# put the first line back into the clipboard
zeus.set_clipboard_text(results[0])
else:
# leave it up to default behaviour
zeus.MarkCopyEx()
key_macro() # run the macro