Allow prevention of text entry of typed control characters
Fix #13279
Floating this as a "first step" to a solution as a RFC (request for comments). Still has a TODO if it is liked: a preference setting to enable/disable ?
After some quick experimenting with the debug build, and that seems a good starting point.
I would definitely support a preference setting for this one: I would suggest in the Non-printing Characters section. (And actually, because it would have to grow that box, I might suggest swapping Non-printing Characters to Editing 2, and moving Multi-Edit back to Editing 1. Then Editing 1 could become just Editing again, and Editing 2 could become Non-printing Characters or maybe something more simple, like Characters -- and with that name, then EOL (CRLF) could also move to that page.)
Addendum: I forgot to say, the reason I think it would be better as a preference rather than always active (or zero-byte-file) is because usually I would want to just disable entering those characters. But there may be times when I want to temporarily switch it to allow me to enter the control characters (without having to restart the application).
But there may be times when I want to temporarily switch it to allow me to enter the control characters (without having to restart the application).
Double-clicking here will still insert the control character:
(But, I agree with a new preference setting for the feature of this PR)
@donho
Looking for a yes/no on the basic idea here. If a "yes" then I will add a preference setting or zero-length xml file or whatever is wanted to control the behavior.
@alankilborn
Looking for a yes/no on the basic idea here.
Maybe :D (BTW, I always want to build a dialog with 3 buttons: "Yes", "No" & "Maybe")
If a "yes" then I will add a preference setting or zero-length xml file or whatever is wanted to control the behavior.
The feature deserves a GUI option - where you think to put this option more suitable?
The feature deserves a GUI option - where you think to put this option more suitable?
As Peter suggested earlier, it could go here where the yellow is:
It could also simply be put on the Editing 2 page.
Either way, I envision it as a checkbox: "Prevent control character typing into document"
Still Yes / No / Maybe ? :-)
As Peter suggested earlier, it could go here where the yellow is:
Yes, I think it'll be the better place.
Either way, I envision it as a checkbox: "Prevent control character typing into document"
If it'll be in "Non-Printing Characters" section, is it rather "Prevent non-printable character typing into document" ?
Still Yes / No / Maybe ?
If the answer were no, there wouldn't be The feature deserves a GUI option... :)
However, there will be no enough room to add the option.
I'll move some options from "Editing 1" to "Editing 2".
Once it's done (I'm doing it), you can continue this PR (rather close this one and do a new PR by being based on the master).
What do you think?
@alankilborn
I'll move some options from "Editing 1" to "Editing 2". Once it's done (I'm doing it), you can continue this PR (rather close this one and do a new PR by being based on the master).
It's done in 12548b6. Just uncomment this line: https://github.com/notepad-plus-plus/notepad-plus-plus/commit/12548b6abb607de94163e9171908de4a1b7a718c#diff-e5c81a5d2fb35d00259941d97465c669073c5f49060dee607b1a1c670736a385R130 then you can continue this the coding of this PR (Please create a new PR as I suggested).
@alankilborn
Either way, I envision it as a checkbox: "Prevent control character typing into document"
Will you still want to link the GUI option to the feature you have done in this PR? Or I merge this PR as it is, and I can continue the implementation.
Or I merge this PR as it is, and I can continue the implementation.
YOU can go ahead with it -- thanks -- I think it (the code) is all there (in the other PR) except the pref. setting if() wrapper, right?
Maybe I’m too late with this...
I have to think anyone who is randomly typing Ctrl+ combinations with any frequency could hardly be able to use a computer keyboard at all. I can see, though, that if you type one of these combinations by accident (and we all make occasional mistakes) and View | Show Symbols | Show control characters... is off, you can’t see that you typed it.
Just floating an idea... perhaps a setting could be avoided by making this contingent on the View | Show Symbols setting. If you can’t see the character, you can’t type it. If you can see it, it will be easy enough to recognize it and delete it, so the suppression won’t be needed.
@Coises
Maybe I’m too late with this...
Not at all. I just began for the implementation.
Just floating an idea... perhaps a setting could be avoided by making this contingent on the View | Show Symbols setting. If you can’t see the character, you can’t type it. If you can see it, it will be easy enough to recognize it and delete it, so the suppression won’t be needed.
If I understand you, what you have suggested is checking the visibility of control characters to determinate the ON or OFF of this feature (C0 visible -> can Type; C0 invisible -> Cannot type), instead of using GUI option.
It could confuse people IMO, I can imagine the following scenario:
The visibility of C0 is OFF, user type Ctrl-E on purpose, nothing happen, but user think ENO is keyed in.
With the GUI option, user turns it ON or OFF, no ambiguity. My question is, what's the value by default? ON or OFF?
@Coises ,
randomly typing Ctrl+ combinations with any frequency could hardly be able to use a computer keyboard at all
It annoyed me when you said this before, but I couldn't articulate why at that point. But thinking about it again, I believe I've figured out something that might make sense to you:
If we are trying to encourage someone who is coming from VSCode (or any other editor) to use Notepad++ instead, they may have a Ctrl+___ keyboard shortcut that they are used to, which isn't bound to any action by default in Notepad++. In this case, it's not "random typing"; it might be their muscle-memory that needs training for Notepad++. That's nothing to insult them over, but rather applaud their new choice in text editor.
And one of the benefits of this feature is to give those people the choice of whether it's better for training their muscle-memory to insert weird characters, or better to train their muscle-memory to not insert any characters with those keystrokes -- depending on the person, they might prefer to be trained by it doing nothing, or prefer to be trained by seeing a weird character; either way, who are we to judge (or to accuse them of "random typing" or being incapable of using a computer keyboard).
@donho,
My question is, what's the value by default? ON or OFF?
If the default is OFF (so it doesn't prevent the characters), there is no change in default behavior -- which means fewer complaints as issues here or posts in the forum. But as Alan is fond of pointing out, for good features, keeping them off by default means that more people don't find out about the feature.
Despite my mention of complaints, I would think this feature wouldn't get a lot of complaints even if it were defaulted ON. Since I'm willing to say that, I guess that means I'm willing to deal with the complaints in the Forum as they arise. ;-)
So my vote is ON.
someone who is coming from VSCode
Probably no one migrates from VSCode to Notepad++. :-)
If the default is OFF (so it doesn't prevent the characters)...
Default should be ON. Prevent the characters. In the unlikely event that there's someone out there that inserts some control characters using the keyboard, that user can post a question to the forum and I'll gladly tell them how to restore their favorite behavior.
No offense, but I think @Coises is misguided.
Scenario:
Novice user fat-fingers Ctrl+e and gets an ENQ inserted into his document. User has absolutely no idea what this crazy white on black ENQ is, and how to get rid of it. User figures out they can backspace delete it, but is left wondering how they got that in there anyway.
Better to just prevent the fat-fingering incident in its entirety (user never sees anything).
I apologize for what, in retrospect, was a flip or even insulting tone in my remarks.
For what it’s worth:
Since pretty much everyone else’s sense of this is opposite of mine, I can accept that my intuition in this case is misguided.
I agree that the default should be to suppress the control-character generation. The only combination which leads to silently broken files is the one in which the user did not intend to enter a control character, viewing control characters is off, and a control character is entered. We can’t change the first and wouldn’t want to mess with the second, so making the third default to the “safe” value is the sensible choice.
No offense, but I think @Coises is misguided.
Scenario: Novice user fat-fingers Ctrl+e and gets an
ENQinserted into his document. User has absolutely no idea what this crazy white on blackENQis, and how to get rid of it. User figures out they can backspace delete it, but is left wondering how they got that in there anyway. Better to just prevent the fat-fingering incident in its entirety (user never sees anything).
This is actually the good case. I was typing Ctrl+e or something similar without showing the hidden symbols and wondering for too long why one string didn't match another.