| View previous topic :: View next topic |
| Author |
Message |
gwgs
Joined: 21 Nov 2006 Posts: 67
|
Posted: Sun Dec 05, 2010 9:42 pm Post subject: bug with copying text from start of folded text |
|
|
This occurs in Zeus 3.97c. I'm using windows 7
Sample Text:
| Code: | function abc (def, ghi):
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890 |
When folded:
| Code: | | function abc (def,ghi): ... |
select abc and copy to clipboard, when you paste you get a column of text from the folded block, eg
| Code: | abc
678
678
678
678
678
678
678
|
Not useful when all you want is the function name in this case.
Please fix.
Thanks in advance
Grant Smith |
|
| Back to top |
|
 |
jussij Site Admin
Joined: 13 Aug 2004 Posts: 1938
|
Posted: Sun Dec 05, 2010 11:12 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
gwgs
Joined: 21 Nov 2006 Posts: 67
|
Posted: Sun Dec 05, 2010 11:48 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
jussij Site Admin
Joined: 13 Aug 2004 Posts: 1938
|
Posted: Mon Dec 06, 2010 1:56 am Post subject: |
|
|
| Quote: | | 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: | 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 |
|
|
| Back to top |
|
 |
|