Foreground options for Selected text?



  • 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

    http://sourceforge.net/projects/npp-plugins/files/NppExec/NppExec Plugin v0.5.3/NppExec_053_dll_Unicode.zip/download

    • 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.

    1. Edit startup.py
    2. 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



  • @jbrosecity

    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?


Log in to reply