Foreground options for Selected text?
-
HI - I just joined the community. I hope General Discussion is the right place for this query. I am new to Notepad++. I have been using Textpad for many years but I recently got fed up with them because they have never taken the rather obvious suggestion of allowing one to scroll font size up and down like almost every other Windows application. For aging eyes this is a must. I found Notepad++ does this and a whole lot more. I have spent some time in Style Configurator and am pretty happy with all the options, except that for some reason when I highlight or select any given text the font color or foreground remains the same. In most applications, as in Textpad, when you select text this applies the background color and the foreground goes to white. Even in the Style Configurator window itself, when any item under Style is selected the item is highlighted in blue and the text changes to white. It would be almost impossible to read it if it remained black. I’m working around this by using a fairly light color for highlighting, so I can still read the black through it, but I would prefer a darker highlighting with white font or foreground. Is this possible? Am I missing something? Thanks for any help here.
-
Hello jbrosecity,
I don’t think that you can, easily, change the foreground colour of the selected text, ONLY. Indeed, the modification of the foreground colour is impossible, with the Style Configurator feature :-((
As a work-around, of course, you may change the foreground colour of the Default Style style. If so :
-
To change the foreground colour of the normal text ( Selected or NOT ) :
-
Select the menu option Settings - Style Configurator…
-
Select the Default (stylers.xml) theme
-
Select the Global Styles language
-
Select the Default Style style
-
Click on the Foreground colour square, to choose a new colour
-
-
To change the background colour of the selected text
-
Select the menu option Settings - Style Configurator…
-
Select the Default (stylers.xml) theme
-
Select the Global Styles language
-
Select the Selected text colour style
-
Click on the Background colour square, to choose a new background colour
-
-
Finally, click on the Save & Close button, to save your changes
Of course, if you currently use a theme, different from the default one, you’ll have to adapt this method !
IF you prefer to change the colour of the selected text ONLY, you’ll have to exploit the Scintilla notification SCI_SETSELFORE
Refer to the link below :
http://www.scintilla.org/ScintillaDoc.html#SCI_SETSELFORE
In order to run that command, two solutions are available :
-
Use the NppExec plugin
-
Open the ^NppExec console
-
Type the command SCI_SENDMSG 2067 1 C, where :
-
C is the decimal result of the operation
Blue * 65536 + Green * 256 + Red
-
Blue, Green, and Red are the value of each colour, in the range
[0-255]
-
-
Hit the Enter key to valid this command
-
For instance the command
SCI_SENDMSG 2067 1 255
, followed by Enter, will change the foreground colour of the text of any selection, in pure red. On the same way, you may change the background colour of the selection, with the command SCI_SENDMSG 2068 1 C- Use the Python Script plugin
I’m not acquainted to Python Script yet, so I, just, can tell that you’ll have to use, in a new script, the two commands Editor.setSelFore(1, fore) and Editor.setSelBack(1, back), where, fore, and back are the decimal value, discussed above !
Quite sure, that Claudia could do something about it !!
Best Regards,
guy038
-
-
Thanks for the quick reply Guy. I tried the first suggestion to “change the foreground colour of the Default Style style.” but that did not accomplish the goal of changing the foreground colour to white within selected text. It remains black in HTML. It did however change the “=” (equal signs) in HTML to white which of course is not useful for HTML as they all then disappear against white page. So I changed it back. The Sintilla suggestion is way above my pay grade. I am just a lowly HTML coder… I don’t know a thing about programming or python or whatever.
I did note of course that “foreground colour” is greyed out when using the “selected text color” option of the Global Styles. I think that is the shortcoming. As I said it is a default behavior in almost any windows utility or browser, when you select the text it changes color. Even in this field where I am typing this reply, If I doiubleclick on a word to select it, the text immediately changes color to white so it can more easily be read against the dark blue selection color. Standard stuff.
So maybe Claudia could do something about this in the next release. Simply activating the “foreground colour” option out when using the “selected text color” would take care of it so if there is some reason why someone would NOT want the foreground colour to change in selected text they would have that option. In Textpad, this is indeed the case, and BOTH foreground colour and background colour are configurable in selected text.
Thanks again…
-
Hi, jbrosecity,
Oh, yes ! I just spoke about default normal text, only. Of course, with the usual HTML highlighting, the use of the Style Configurator… seems rather useless :-(( You could have a try, changing the foreground colour of the DEFAULT style of the HTML language, too, but I don’t think it’s worth to, unfortunately !
But, using the Scintilla notification, and the example, given in my previous post, would change, for any language, the foreground colour of text, in a selection, of any tab of the active view ( main OR secondary ) to the red colour. So, it would overwrite the normal highlighting of any built-in or user language ! May be, it’s exactly the behaviour that you’re are looking for ?
You may have a try ! Let’s go :
- Download NppExec v0.5.3, from the link below
-
Close any instance of Notepad++
-
Extract all the contents of this archive, in the plugins folder of your N++ configuration
-
Re-start Notepad++
-
Click on the new Show Console Dialog button of the Toolbar OR choose the menu option Plugins - NppExec - Show Console Dialog
-
In that NppExec console, just type the command SCI_SENDMSG 2067 1 C, where C is a number between 0 ( Black ) and 16777215 ( White ). You may choose the value 255 ( Pure Red ), to begin with !
-
Finally, select some text, in HTML or else, in the main editor. Do you like it ?
If so, you’d better have a look to the NppExec help file, first, selecting the menu option Plugins - NppExec - Help/Manual. Remember that, with NppExec, you can write scripts and, also, run scripts on N++ start and/or N++ exit !
If you still want to ask for this new feature, you should create a new pull request, at the address :
https://github.com/notepad-plus-plus/notepad-plus-plus/pulls
But, I’m afraid that you’ll have to be patient, because some other requests should have a higher priority !
Cheers,
guy038
P.S. :
BTW, when I wrote :
Quite sure, that Claudia could do something about it !!
I just meant that Claudia is a definitive Python’s fan !! So, she’s certainly able to write a tiny script, to set this property for foreground selected text :-)) I may be mistaken, but I don’t think that Claudia Franck is part of the contributors’s team of N++
-
Hello @jbrosecity
guy038 did it already. If you are just looking for a white foreground color (font) then the command is
editor.setSelFore(1,(255,255,255))
That’s it.
To test it, download and install the python script plugin using plugin manager.
Once done, start the python script console by using the menu Plugins->Python Script->Show Console
and put this line into the textbox next to the Run button of the console.
Press enter or Run button. Done. Now the selected Text should be in white.As said, this is for testing, a temporary solution. When you restart npp everything is reset to the old values.
To make this persistant you need to add this line into the startup.py which has been automatically created
during installation of the python script plugin.
Therefore open the YOUR_INSTALLATION_PATH\Notepad++\plugins\PythonScript\scripts\startup.py with
npp and add the line on the end of the script.... sys.stdout = editor # <- this line already exists and should be the last line, as far as I remember editor.setSelFore(1,(255,255,255))
But there is one more thing to do. You need to change the configuartion of python script plugin.
Menu Plugins->Python Script->Configuration and change Initialisation from LAZY to
ATSTARTUP. Restart npp. Now you should always have the white foreground color.So, basically two steps needs to be done.
- Edit startup.py
- Change startup mode
@guy038 - 100% sure - I’m not a npp code contributor. If I would write c/c++ code it would be like
giving a boy the RED button to play - not a good idea ;-) Thx for the kind words.Cheers
Claudia -
Well after going sailing all afternoon, I returned to find guy and Claudia’s posts. First I tried guy’s suggestion using ‘NppExec console’ using the command SCI_SENDMSG 2067 1 16777215 - but to no avail. Selected text still remains it’s original color beneath my medium blue select color. Then I tried Claudia’s solution installing the python plugin with the plugin manager. But every time I go to Plugins->Python Script->Show Console all I get is “unknown exception” - another epic fail. Searched my drive for startup.py and it doesn’t exist on my system. PythonScript.dll is there as is python.xml … but no py file. Sigh. I really appreciate everyone’s helpfulness… Reminds me of the old days of USENET, but as I said before, all this programming is way above my pay grade. I just piddle around with a little HTML code… probably should just go back to Textpad :-/
-
Hello jbrosecity,
may I ask you which npp and windows version you use?
An unknown exception can’t be the reason to give up, can it be? ;-)Cheers
Claudia -
in case you have windows 10,
I did some test with my win10 and found out,
that installation via the plugin manager isn’t fully done.
The subdirectories are missing. I assume permission problems, not yet verified.
I downloaded the msi installer package, which you can get from here
and run the installation. Worked, directories are created and
show console works also.Cheers
Claudia -
Hi Claudia… I’m using NPP 6.8.8 and Windows 7, with. all current updates as of yesterday :-) By the way, for Guy’s suggestion, he neglected to say hit “enter” after entering the command "SCI_SENDMSG 2067 1 16777215 " in the NppExec console. For whatever reason I just tried it again and hit enter after pasting in the command and voila! the highlighted text above immediately went to white. NICE! Unfortunately it is temporary, apparently… You can run it each time you open NPP, I guess and closing the console I see still leaves the command in force, but not between sessions. I wish I could enter some line on one of the config files to make this the default behavior. I see that I can “Direct execute previous” with CTRL+F6 which is fairly automated, but it sure seems like a lot of trouble to go thru for something which is essentially a Windows standard feature. Even the world’s most featureless text editor, the ultra basic Notepad, exhibits this standard behavior. Hard to believe it was left out of something as sophisticated as NPP :-/
-
Claudia… WOW. I’m about to sign up for computer programming classes at the local junior college! I can’t believe I pulled this off! OK I saw your post about Windows 10, and as I said I’m using Win 7 but I thought what the heck so I downloaded your file and used the contents to overwrite what was previously installed with plugin manager. Then I was indeed able to open the python console, so I entered “editor.setSelFore(1,(255,255,255))” and lo and behold it made the text go white. So THEN searched for startup.py which came right up. It would not let me edit the file iC:\Program Files (x86)\Notepad++\plugins\PythonScript\scripts\startup.py, but I copied it to another directory, edited it there and then cipied I back over the one Prog Files and with “permission” it let me do it. Opening it again, sure enough the change took. Then finally I changed the Configuration Initialisation from LAZY to ATSTARTUP and voila! Now when I selected any text it acts just like Windows Notepad, Textpad, my browser and just about everything else and the selected text foreground changes to white! Thanks so much… This took wayyy too much time and energy but I can go to bed tonite with a real feeling of accomplishment. I’m gonna document all this in my notes for future installations, That was FUN! Übrigens, Claudia… Ihre Deutsch is viel besser wie meine mit Günter Leipfinger :-) Wenigens, habe Ich probiert!
-
Hello jbrosecity,
I’m glad you’ve finished it. And after a day of sailing and programming (btw. I would bet that your html coding is much more
complex than this one liner ;-)) you well-deserved the real feeling of accomplishment ;-) And it’s all about FUN, isn’t it.
Regarding my german, well, what should I say - my father was german so it wasn’t that hard but your german
is better than my english.Cheers
Claudia -
Claudia wrote : “but your german is better than my English.” Daß glaube Ich gar night! Danke vielmals, liebe Fraülein, oder soll Ich Gnädige Frau sagen? Jedenfalls, danke schoen… Ich bin jetzt froh weisses ‘text’ zu haben! Gute Nacht!
-
Hello jbrosecity,
Ahhhhh! Of course, I forgot to tell you to hit the enter key, to valid the command. You know, it’s sometimes difficult to appreciate if we provide sufficient information, or NOT, while writing a post !
Secondly, you surely didn’t notice it, but I said, in my previous post :
Remember that, with NppExec, you can write scripts and, also, run scripts on N++ start and/or N++ exit !
So, here’s, below, the method to, automatically, set the white colour to selected text, while opening Notepad++ :
-
Select the menu option Plugins - NppExec - Execute…, or type on the F6 key
-
Type the two lines, below, in the dialog :
NPP_CONSOLE ?
SCI_SENDMSG 2067 1 16777215
-
Save this script, with the name, let say, White_Selected
-
Select the menu option Plugins - NppExec - Advanced Options…
-
On the top right corner of this new dialog, choose your White_Selected script, under the mention Execute this script when Notepad++ starts:
-
Valid this change of the dialog, with the bottom OK button
-
Close and re-start N++
Et voilà ! From now on, any selected text should be displayed with foreground white colour, even if the language of the current document has its own highlighting rules !
Note : the NPP_CONSOLE ? command keeps the present state of the NppExec console. If it’s already opened, it will stay open, after running the script. If it’s was closed, it will remains closed
Enjoy Notepad++ !!
Best Regards,
guy038
P.S :
I’ve just noticed that you already got a solution, with the Python script plugin and Claudia’s help. So, now, you have two possible solutions ! Isn’t nice ?
-
-
Hiya Guy! Thanks for the alternate solution with the NppExec console. I saved Claudia’s python instructions to my programs notes file. I’ll add yours just because you took the time to type it up for me. And yes it IS fun to have multiple options. It is what I have always loved about computer software. If you can imagine it, you can do it! (Most of the time). While not a programmer at all, myself, I have run my own software business for nigh on 20 years now. Rose City Software. I am more of designer and marketer and have had the distinct pleasure of working with some great programmers over the years using C++, Delphi, and other languages… but they write the code, I just come up with and collect customer feedback for features and UI enhancements and then manage the sales and upgrades. It has been a fun and rewarding business the last couple decades and though semi retired now and traveling in my motorhome, I keep involved from my recliner with my laptop and a 4G Verizon connection. It keeps my mind active as I am just beginning my 8th decade. The rest of the time I just like to go sailing on my Catalina sailboat TheAnneMarie-dot-com :-) Thanks again Guy and Claudia… this has been a real pleasure!
-
I just checked back today to see if there had been anything new on this thread… and I see not. But I also see it has been the most often viewed thread in a while, so obviously there is some interest in this. I am grateful to Claudia and Guy for helping me get thru this, and with my selected text now appearing white against a dark blue background, I could not be happier with Notepad++. It was a fun challenge to set up python and jump through the hoops to get it to do this, but maybe the developers will take the clue and realize this is a major oversight, and there is plenty of interest in how to do this… and thus perhaps they will enable the option for foreground color with selected text in a future release. After all it is standard Windows behavior and virtually every other software I use, even the featureless Windows Notepad. handles selected text this way.
-
I would like to raise this old thread and ask - why so far the author not yet made this modification of the foreground colour in the Style Configurator?
-
It’s been almost THREE YEARS since this was last replied to and I don’t see any changes on that very basic missing feature that requires hacks described here.
Before I found out about the nppexec hack, not being able to define the “selected text” color was THE issue that prevented me from using Notepad++ as I am working on as many applications as I can with light text on a dark background, after suffering for far too long working on white backgrounds ever since it became fashionable when Macs and Windows came out with the erroneous belief that ‘paper white’ backgrounds are better for you, when, in fact computer white screens are NOT like paper, but rather much more like looking at a blinding flashlight. Fortunately, this is finally being realized as a second generation of computer users are demanding a remedy and now so many web sites and plugins and applications have ‘dark mode’ available.
Isn’t it high time for Notepad++ developers to make this fundamental, basic missing feature a priority? Am I correct in guessing the only reason that hasn’t been done so far, is that it would require a complete rewrite of the basic Notepad++ code?
For those using Notepad++ with dark grey background (RGB 16,16,16) with normal text as 192,192,192, using the nppexec plugin (nppexec.dll in \plugins\nppexec) and looking for a quick way to get the selected text to inverse these colors (in effect, get your selected text to be that of the background and the selected area to be that of the normal text color, as a true inverse), here’s my code:
put these in \plugins\config:
npes_saved.txt:
::Black_Selected
NPP_CONSOLE ?
SCI_SENDMSG 2067 1 1052688nppexec.ini:
[Options]
ScriptNppStart=“Black_Selected”
[Console]
Visible=0
ShowHelp=0
Encoding=17
SaveOnExecute=0
CmdHistory=1
SaveCmdHistory=1
TextColorNormal=0(6)
TextColorError=A01010
TextColorMessage=208020
BackgroundColor=00
NoInternalMsgs=0
[Restore]
LastSelectedScript=1Remember, the key part you need to customize to get the highlighted text to be that of your normal background color (when set as RGB 16,16,16) is the line:
SCI_SENDMSG 2067 1 1052688
The last number is what determines the color of the text when selected, using this formula: (65536blue value)+(256green value)+(red value) - note, it’s in the inverse order of the customary RGB order - transposing 16 for each B, G and R (my normal background color), you get 1052688 while the selection itself is set in the Stylers configuration as 192,192,192 (same as my normal text font color).
Sorry if it comes as a rude wake up after three years, but I thought it needed to be said. Hope the nppexec code helps beginners as a starting point to experiment with.
-
@JohnnyJim-J said in Foreground options for Selected text?:
It’s been almost THREE YEARS since this was last replied to and I don’t see any changes on that very basic missing feature that requires hacks described here.
…
Am I correct in guessing the only reason that hasn’t been done so far, is that it would require a complete rewrite of the basic Notepad++ code?
…
Isn’t it high time for Notepad++ developers to make this fundamental, basic missing feature a priority?As far as technical issues are concerned, I don’t know if there’s a reason it would be hard to be implemented or not. But if it does require a complete rewrite, then it’s not going to happen.
As far as practical reasons, it probably comes back to one return question: Did anyone involved in this thread ever create an official feature request? (I’ll give you a hint, posting in this forum is not an official feature request; see the FAQs for more.) If not, then that is the essential reason why. If an official request is ever made, then at that point, the developers can decide whether or not to prioritize working on it, depending on how useful they think it is.
Sorry if it comes as a rude wake up after three years
It’s not any form of wake up to the developers, because they’re basically uninvolved in the vast majority of discussions in this Community Forum, so your post likely isn’t on their radar at all.
-
@PeterJones said in Foreground options for Selected text?:
As far as technical issues are concerned, I don’t know if there’s a reason it would be hard to be implemented or not. But if it does require a complete rewrite, then it’s not going to happen.
As far as practical reasons, it probably comes back to one return question: Did anyone involved in this thread ever create an official feature request? (I’ll give you a hint, posting in this forum is not an official feature request; see the FAQs for more.) If not, then that is the essential reason why. If an official request is ever made, then at that point, the developers can decide whether or not to prioritize working on it, depending on how useful they think it is.
.
It’s not any form of wake up to the developers, because they’re basically uninvolved in the vast majority of discussions in this Community Forum, so your post likely isn’t on their radar at all.Thanks for the quick checkup 👍 Too bad the developers are not checking the forum like they do with other apps, where the developer checks in on users and gets involved directly, implementing features later on depending on demand and whether it interferes with general operations or not (ie whether it’s a bug, a feature request or whether a ‘problem’ is not in fact a ‘feature’).
-
@JohnnyJim-J said in Foreground options for Selected text?:
Too bad the developers are not checking the forum like they do with other apps
I think the developers spend their time in the official issues list.
There are at this moment 1273 open issues.
So I think they’ve got enough to do there without monitoring here as well.
In a perfect world they’d have time to do both, but…