Emerald Editor Discussion
October 21, 2017, 11:21:12 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1] 2 3 4
  Print  
Author Topic: Committed Empty Line pasting option  (Read 28900 times)
0 Members and 1 Guest are viewing this topic.
Pvt_Ryan
Master Jeweller
******
Posts: 422



WWW
« on: March 29, 2007, 12:19:57 am »

See this bug: http://bugs.emeraldeditor.com/showreport.php?bugid=3

Modified CE to allow users to enable / disable the ability to paste empty lines.

Tools > Preferences > General > Allow empty line(s) to be pasted.

disabled by default

NOTE:
BACKUP YOUR CURRENT CFG FIRST!!!
You may get the CE error message about the cfg being corrupt when this version is first started, i think this is due to where i placed the option in the cfg file but as far as i can see it doesn't actually affect the cfg.

Please let me know if it does & what is affected.
« Last Edit: March 29, 2007, 12:33:31 am by Pvt_Ryan » Logged
Phil
Administrator
Master Jeweller
*****
Posts: 427


« Reply #1 on: March 29, 2007, 03:31:38 am »

I think the bug is that an empty line can be copied to the clipboard when nothing is selected, not that empty lines can be pasted. I really don't think that there should be an option about this at all. Of course empty lines should be able to be pasted if empty lines were selected and copied, but the problem is when nothing is selected and Ctrl+C is hit and the line is empty, CE should not copy the empty line to the clipboard according to whoever posted that "bug." I actually think that it is not a bug at all.

The problem isn't paste; it is copy.

Just my opinion,
Phil
« Last Edit: March 29, 2007, 03:37:24 am by Phil » Logged
KjeBja
Senior Miner
***
Posts: 76


« Reply #2 on: March 29, 2007, 06:33:00 am »

I agree with you, Phil, it's the copy that's the problem; copying just one empty line is meaningless. However, this "bug" made me aware of the fact that you don't actually have to select a line to copy it, and as I am all for any time-saving and keystroke saving features, this is really to my liking.
« Last Edit: March 29, 2007, 06:40:48 am by KjeBja » Logged
Pvt_Ryan
Master Jeweller
******
Posts: 422



WWW
« Reply #3 on: March 29, 2007, 07:22:48 am »

ok have change the code abit..

it now performs the check if you copy or cut and not when you paste.

I have left the option in to turn it on or off as there are times when i copy multiple empty lines on purpose.

IT DOES NOT AFFECT copy or cut APPEND!

NOTE:
A small side effect of me removing the check around the paste is that if you have an empty string already on the clipboard then you can still paste it.
« Last Edit: March 29, 2007, 07:45:57 am by Pvt_Ryan » Logged
Phil
Administrator
Master Jeweller
*****
Posts: 427


« Reply #4 on: March 30, 2007, 12:25:33 am »

Haven't tested yet, but that sounds better.

Thanks,
Phil
Logged
John Yeung
Senior Miner
***
Posts: 85


« Reply #5 on: March 30, 2007, 02:46:17 am »

However, this "bug" made me aware of the fact that you don't actually have to select a line to copy it, and as I am all for any time-saving and keystroke saving features, this is really to my liking.

While saving time and keystrokes are important, I think it's even more important that things work the way most users will find intuitive and reasonably safe.  Performing a copy when nothing is selected is neither intuitive nor safe.

John
Logged
Pvt_Ryan
Master Jeweller
******
Posts: 422



WWW
« Reply #6 on: March 30, 2007, 09:47:10 am »


While saving time and keystrokes are important, I think it's even more important that things work the way most users will find intuitive and reasonably safe.  Performing a copy when nothing is selected is neither intuitive nor safe.

John


While I realise you are fighting my case, for this "feature", I am slightly inclined to agree with the earlier posts. As there are times (for me quite often) when you do want the editor to copy & paste blank lines, however I realise that for some people that this may also be the cause of some annoyance. I decided that allowing the user to choose which they wanted was the best way.. If they wanted to work in a "safe" way that they couldnt copy & paste blank lines then they can do so.

Also note that a blank line is just that (a carridge return) and does not include a line with tabs or spaces. I.E. even with the feature to allow the blanks lines to copied disabled you can still copy and paste a line with only tabs or spaces on it.

Although I think tonight i am going to readd the code around the Paste option to prevent empty line pasting when the feature is disabled and I am going to invert the reasoning so instead of ALLOW cutting & copying the option will be DISALLOW.


Thoughts?
Logged
Pvt_Ryan
Master Jeweller
******
Posts: 422



WWW
« Reply #7 on: March 31, 2007, 12:42:10 am »

Ok have committed the changed logic & wrapped the paste event incase option is enabled & there is an empty line on the clipboard from another app. rev 109
Logged
John Yeung
Senior Miner
***
Posts: 85


« Reply #8 on: March 31, 2007, 02:07:22 am »

My idea of "nothing selected" means truly NOTHING selected.  A carriage return isn't nothing.  If you put your cursor at the end of a line (which may be the same as the beginning of the line if there are no other characters on it) and you hold down Shift and press the right arrow to move the cursor to the beginning of the next line, you have selected something.  When I do this in Crimson on a line which has no trailing spaces, the selection highlight extends a bit beyond the last visible character of the previous line, to show that I have indeed selected something.  At this point, if I were to press Ctrl+C, I would expect that my clipboard contains an end-of-line (in this case, CR+LF).

If I move the cursor around without holding Shift, I don't see anything highlighted and I expect NOT to be selecting anything.  If I press Ctrl+C at any point while nothing is selected, I would expect (and hope!) that my clipboard is unaffected.

A harsh alternative to this behavior is for Ctrl+C to clear the clipboard if nothing is selected.  Then, if I try to paste, nothing happens, because there is nothing in the clipboard.  While I can follow the logic of this alternative, I don't think the ability to clear your clipboard with Ctrl+C is of much benefit, while you could easily lose your clipboard contents by accident.

Crimson's current behavior isn't quite either of these.  What happens now is that if I move the cursor around without holding down Shift, and have nothing selected, when I press Ctrl+C the entire current line, including CR+LF, is copied to the clipboard.  It doesn't matter where on the line I am, the whole line is copied.  While this might be a great shortcut, it doesn't follow the pattern of SELECTING something to copy it.

It also isn't symmetrical:  Say you are in the middle of a line of text, and the next line also has the same amount of text.  With nothing selected, press Ctrl+X.  The line you are on disappears, the cursor stays where it is, and the next line moves up, so you are now at the middle of the next line.  Now press Ctrl+V.  The first line gets inserted at the cursor, creating a mess.

It simply isn't very logical or intuitive.  It is fast if you know how to use it, and you are specifically trying to work with chunks exactly one line long.  But most people wouldn't know about it and wouldn't want it to behave that way and wouldn't be at all happy when it did.  If enough people think it is handy, maybe it should be preserved as optional behavior and CLEARLY DOCUMENTED.  Personally, I don't think it is handy enough to justify such ridiculous quirkiness. 

At the very least, if copy and cut with no selection are going to work on the entire current line, then paste should be altered to match.  (That is, if nothing is selected when you press Ctrl+V, then push the entire current line down, taking the cursor with it, as many lines as necessary to insert the clipboard contents.  Note that if the clipboard doesn't end with a CR+LF, then a CR+LF should be added, to preserve the line-oriented behavior.  Really, I don't know why I am still talking about this.  I feel like I'm creating some kind of vi variant.)

John
Logged
Phil
Administrator
Master Jeweller
*****
Posts: 427


« Reply #9 on: March 31, 2007, 03:51:54 am »

Here's my opinion about this. I think an option is good because there seems to be disagreement about whether this feature is nice or not. However, I think the option should be not just for blank lines. I think it should be somethink like "Copy current line on copy without selection" (or different wording) instead of copy empty line. I think the option now is too specific. It should enable/disable copying when nothing is selected, regardless of what is on the line.

Also, I still don't think paste should be modified either way because even if the feature was disabled, you would never want to prevent the user from pasting whatever text is in the clipboard.

So, in short, I think paste should stay the same and the option should enable/disable copying the current line (not necessarily empty) when a copy command is made and nothing is selected.

Phil
Logged
Pvt_Ryan
Master Jeweller
******
Posts: 422



WWW
« Reply #10 on: March 31, 2007, 01:02:32 pm »

@ John

You make some interesting and valid points, From my understanding (which is still a bit limited) the way CE works is as follows;
(I will use copy but the effect is similar with cut)

If nothing (i.e. cursor is just sat blinking on a line with nothing highlighted) is selected and copy is press then CE copy's from the cursor position to the end of the line. It is this behaviour that is having the problem as when the cursor is sat on a line that contains a \r\n then it copy's the \r\n and nothing else, the string copied has a length of 0 and contains \r\n.

I'll have to look into how it handles copying etc a bit more..

Would an acceptable solution be an option allowing current mode and "protected" mode where it will not copy unless something is selected?

@ Phil,

The way my modification works is it gets the length of the data stored on the clipboard and if that length is 0 and the option is disabled then it will not paste. (see answer to john above)
Logged
John Yeung
Senior Miner
***
Posts: 85


« Reply #11 on: March 31, 2007, 11:08:50 pm »

If nothing (i.e. cursor is just sat blinking on a line with nothing highlighted) is selected and copy is press then CE copy's from the cursor position to the end of the line.

That isn't the behavior I've observed.  I'm using 3.60 on WinXP, and copy with no selection copies the entire line that the cursor is on, no matter where the cursor is.

...the string copied has a length of 0 and contains \r\n.

I think this may be confusing for some people.  It's a little confusing for me, at least.  To me, length 0 means zero characters.  By my reckoning, a string containing "\r\n" has a length of either 1 (if newlines are treated logically as one character) or 2 (if every encoded character is counted).  I have not looked at the code, so perhaps you are referring to a length function which doesn't count newlines, or doesn't count the last newline, or something.  What is the length of the string "foo\r\nbar"?  Or "foo\r\nbar\r\n"?

Would an acceptable solution be an option allowing current mode and "protected" mode where it will not copy unless something is selected?

That would be my preference.  If nothing is selected (so nothing is highlighted) then I would like absolutely nothing to happen when I press Ctrl+C or Ctrl+X.  But if it's not too difficult, keeping the "quick line copy" as an option would be nice for some users.

So, in short, I think paste should stay the same and the option should enable/disable copying the current line (not necessarily empty) when a copy command is made and nothing is selected.

As I said, paste should definitely not stay the same if cut/copy behaves the way it does.  If you are going to have line-oriented cut/copy, you really should have line-oriented paste.  I can explain this further if it's not clear what I mean.

John
Logged
Pvt_Ryan
Master Jeweller
******
Posts: 422



WWW
« Reply #12 on: April 01, 2007, 09:39:40 am »

John you need to get the latest Binary (3.70) from the download section and see if the behaviour you are observing is still existent in that version.
Logged
John Yeung
Senior Miner
***
Posts: 85


« Reply #13 on: April 01, 2007, 08:30:16 pm »

John you need to get the latest Binary (3.70) from the download section and see if the behaviour you are observing is still existent in that version.

It behaves exactly as I described.  Not surprisingly, this was unchanged between 3.60 and 3.70.

John
Logged
Matthew1344
Gem Cutter
****
Posts: 103


« Reply #14 on: April 02, 2007, 08:31:02 pm »

I am observing the same as John.
Logged
Pages: [1] 2 3 4
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.091 seconds with 18 queries.