Change background color of function tool-tip in notepad++
Asked Answered
J

1

6

I have already gone through following but that's not the issue here.

How to change background color in the Notepad++ text editor?

I am programming in python using notepad++ and applied Deep Black theme in which have a black background and white text color.

While typing a function it shows function syntax in a tool-tip having white background which contrasts with black background of notepad.

GIF explaining flickering effect.

I have already searched in Style Configurator but no luck.

How can I change tool-tip's background color ?

Jarl answered 22/9, 2017 at 11:56 Comment(0)
H
4

Notepad++ uses Scintilla as its editor component. The calltip feature comes directly from scintilla. For scintilla features having no direct configuration options in the gui of Notepad++ (calltip style seems to be such a feature), you need a method to send messages to Scintilla.

One way to do that (and the only one I know of other than programming a plugin) is the use of NppExec plugin. It provides a SCI_SENDMSG command. The scintilla website provides detailed documentation about every possible message. For your use case it says this:

Call tips are small windows displaying the arguments to a function and are displayed after the user has typed the name of the function. They normally display characters using the font facename, size and character set defined by STYLE_DEFAULT. You can choose to use STYLE_CALLTIP to define the facename, size, foreground and background colours and character set with SCI_CALLTIPUSESTYLE. This also enables support for Tab characters. There is some interaction between call tips and autocompletion lists in that showing a call tip cancels any active autocompletion list, and vice versa.

Thus we need to send the SCI_CALLTIPUSESTYLE message and (continue reading on the website) we can configure foreground and background color with SCI_CALLTIPSETBACK and SCI_CALLTIPSETFORE.

So to set the color of the calltip by sending messages to the Scintilla editor component using NppExec, you need do this:

  1. install NppExec with the PluginManager or from PluginCentral. The NppExec zip file contains the dll and some subdirectories. When installing/upgrading into Notepad++ plugin directory, take care that the subdirectories NppExec is created under the plugins directory (just unzip the file into the plugins directory). The NppExec directory contains the file Scintilla.hwhich has all the definitions for the possible messages.

  2. store these lines as a NppExec script (Plugins -> NppExec -> Execute... , enter the following lines and select save, e.g. as SetCallTipStlye):

    // use CALLTIPSTYLE instead DEFAULT
    SCI_SENDMSG SCI_CALLTIPUSESTYLE 0
    // background to black ( 0 )
    SCI_SENDMSG SCI_CALLTIPSETBACK 0
    // foreground to white ( 0xffffff )
    SCI_SENDMSG SCI_CALLTIPSETFORE 0xffffff
    
  3. execute the script with OK

Now your calltip Window should be white on black, you might want to adopt the colors by changing the arguments.

If everything works as you expect, then Plugins -> NppExec -> Advanced Options offers the option Execute this script when Notepad++ starts on the upper right area of the config dialog. Select the script name under which you saved the line (e.g. SetCallTipStlye)

Alas, I have not been able to find out how to configure the autocompletion style. I hoped it would use the same style as the calltip style, but autocompletion stays black on white.

Hon answered 25/9, 2017 at 16:18 Comment(8)
I followed all steps and installed plugin. It's showing following errors when NPP starts in console. - uMsg is 0 (no message to send)Jarl
I get the same error message when using SCI_SENDMSG FOO, e.g. an unknown/invalid message. I am using version NppExec ver. 0.5.3 Unicode for Notepad++ ver. 5.1+ (Plugins -> NppExec -> Help/About) in Notepad++ v7.5.1 (32bit) (? -> About Notepad++) . Which version information do you get for Notepad++ and NppExec?Hon
I have same versions for all i.e NppExec ver. 0.5.3 Unicode for Notepad++ ver. 5.1+ in Notepad++ v7.5.1 (32bit).Jarl
Apart from that I could not find documentation for SCI_SENDMSG on Scintilla. Could you please point me towards it ?Jarl
Upon changing the directory structure it worked. I have added that in answer. Thanks a ton for your research.Jarl
I also researched for changing autocomplete color. But nothing. If you ever get to change it please comment.Jarl
@Jarl SCI_SENDMSG is a NppExec command. Its "documentation" is available via Plugins -> NppExec -> Help/Docs... . Regarding the autocomplete color: at the moment I suspect that it could be related to a Windows color theme setting, but I have no real idea since I use Notepad++ from within Linux via Wine.Hon
Is there any way to make this script work on windows? I has no affect on my pcCarleton

© 2022 - 2024 — McMap. All rights reserved.