Community
    • Login

    Call Tip Color change

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    39 Posts 6 Posters 2.6k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • EkopalypseE
      Ekopalypse @Lycan Thrope
      last edited by

      @lycan-thrope

      c8469e54-3860-4fd6-a403-2e3ec5b0fdf5-image.png

      1 Reply Last reply Reply Quote 1
      • Lycan ThropeL
        Lycan Thrope @PeterJones
        last edited by

        @peterjones ,

        I “Run as Admin”, right click on starting NPP. I am in Admin mode, as far as I know, but still seem to have to open certain things “Run as Admin” when I want to save to admin only areas with applications. I could be wrong, however and it would be the first time. :-)

        First debug info:

        • Notepad++ v8.1.9.3 (64-bit)
        • Build time : Dec 6 2021 - 19:21:37
        • Path : C:\Program Files\Notepad++\notepad++.exe
        • Command Line :
        • Admin mode : ON
        • Local Conf mode : OFF
        • Cloud Config : OFF
        • OS Name : Windows 10 Home (64-bit)
        • OS Version : 2009
        • OS Build : 19043.1466
        • Current ANSI codepage : 1252
        • Plugins : ComparePlugin.dll mimeTools.dll NppConverter.dll NppExport.dll NppXmlTreeviewPlugin.dll PythonScript.dll XMLTools.dll

        This is the Config User Script section:
        PythonConfigUser.PNG

        And this is the file location on the Header bar showing the path to the current file:
        AdminNPPModeShot.PNG

        Lee

        1 Reply Last reply Reply Quote 0
        • Lycan ThropeL
          Lycan Thrope @PeterJones
          last edited by

          @peterjones ,

          Took your hint, Peter, added the two lines you suggested, in the “supposed” auto startup, and it’s not running as far as I can tell. Here’s the screenshot after changing and adding those lines to what I presume is the actual startup file, rebooted NPP, restarted “Run as administrator”, and this is the result:
          ANonrunningscript.PNG

          As you can see, no lines in the console.

          And the prior statement, though tongue in cheek, was a typo also, meaning, it’s not like I haven’t been wrong before so I may well be wrong this time, about being in the Admin mode running my system.

          Lee

          Lycan ThropeL Michael VincentM PeterJonesP 3 Replies Last reply Reply Quote 0
          • Lycan ThropeL
            Lycan Thrope @Lycan Thrope
            last edited by

            @lycan-thrope
            On the off chance I had the first line in the wrong place, I put it below the console redirection, saved, rebooted, restarted as admin and took this shot, still no response:
            ANonrunningscript2.PNG

            Lycan ThropeL 1 Reply Last reply Reply Quote 0
            • Lycan ThropeL
              Lycan Thrope @Lycan Thrope
              last edited by

              @lycan-thrope
              And just in case that asterisk was supposed to be put at the front of the import, I included that again and rebooted and ran, with the same result:

              ANonrunningscript3.PNG

              1 Reply Last reply Reply Quote 0
              • Michael VincentM
                Michael Vincent @Lycan Thrope
                last edited by Michael Vincent

                @lycan-thrope said in Call Tip Color change:

                Took your hint, Peter, added the two lines you suggested, in the “supposed” auto startup, and it’s not running as far as I can tell. Here’s the screenshot after changing and adding those lines to what I presume is the actual startup file, rebooted NPP, restarted “Run as administrator”, and this is the result:

                Not a Python expert, but surprised you’re not getting an error. You only import editor1 and editor2 from Npp, not console, but you proceed to call console. I checked, there doesn’t seem to be a console method in sys so not sure why you’re not seeing an error.

                Maybe your Npp import line should be :

                from Npp import console, editor1, editor2
                

                or better yet, since it’d be beneficial to import all Npp into your PythonScript console:

                from Npp import *
                
                • Did you try not running in Admin mode?
                • Did you try to use the user startup.py located in (assuming from your image):
                  C:\Program Files\Notepad++\plugins\Config\PythonScript\scripts\startup.py

                Cheers.

                Lycan ThropeL 1 Reply Last reply Reply Quote 0
                • PeterJonesP
                  PeterJones @Lycan Thrope
                  last edited by

                  @lycan-thrope

                  So it’s obviously not running the startup.py that you are editing.

                  When i run, I will see:
                  8255846d-0c28-45e5-a89a-3babb4f0216d-image.png

                  or
                  c18414a7-6c86-4e2d-bb81-ec3021bded1d-image.png

                  (so when I change the color and restart notepad++, it changes the color)

                  Running in Admin mode is just asking for trouble. But I tried with my portable setup (the one I am showing), and it still ran my startup script

                  I don’t know what you’ve corrupted, but you’ve done something tp mess it up so it’s not trying to run the startup.py … Please reset to the file below

                  # The lines up to and including sys.stderr should always come first
                  # Then any errors that occur later get reported to the console
                  # If you'd prefer to report errors to a file, you can do that instead here.
                  import sys
                  from Npp import *
                  console.write("START of machine startup.py\n\n")
                  
                  # Set the stderr to the normal console as early as possible, in case of early errors
                  sys.stderr = console
                  
                  # Define a class for writing to the console in red
                  class ConsoleError:
                  	def __init__(self):
                  		global console
                  		self._console = console;
                  
                  	def write(self, text):
                  		self._console.writeError(text);
                  
                  # Set the stderr to write errors in red
                  sys.stderr = ConsoleError()
                  
                  # This imports the "normal" functions, including "help"
                  import site
                  
                  sys.stdout = console
                  
                  # In order to set the stdout to the current active document, uncomment the following line
                  # sys.stdout = editor
                  # So print "hello world", will insert "hello world" at the current cursor position
                  
                  ########## added:
                  for e in (editor1,editor2):
                      e.callTipSetBack((255,255,176))
                      e.callTipSetFore((127,0,0))
                  
                  console.write("END of machine startup.py\n\n")
                  console.show()
                  

                  make sure it’s ATSTARTUP, exit Notepad+ and re-run. If it doesn’t open the console window and show your prints, then you do not have things set up the way you think you do, or you have corrupted some other file with all your messing about.

                  Lycan ThropeL 1 Reply Last reply Reply Quote 2
                  • Lycan ThropeL
                    Lycan Thrope @Michael Vincent
                    last edited by

                    @michael-vincent ,

                    I’m beginning to wonder if I’m supposed to actually have Python loaded. My presumption, is that the Python Script is a fully contained solution. The console stuff being called, is in the default startup.py file. I only modifed and then cutout the section where the console class was, since you said to start fresh, and only paste in such and such, I removed that reference. This is what I cut out of the original startup.py:

                    # Define a class for writing to the console in red
                    class ConsoleError:
                    	def __init__(self):
                    		global console
                    		self._console = console;
                    
                    	def write(self, text):
                    		self._console.writeError(text);
                    
                    # Set the stderr to write errors in red
                    sys.stderr = ConsoleError()
                    
                    # This imports the "normal" functions, including "help"
                    import site
                    
                    #sys.stdout = console
                    
                    # In order to set the stdout to the current active document, uncomment the following line
                     sys.stdout = editor
                    # So print "hello world", will insert "hello world" at the current cursor position
                    

                    Since it wasn’t even printing out to the file the hello world and was only echoing what I was typing in to the console, it didn’t seem to be functioning either. Still, no errors. :-(

                    Lee

                    PeterJonesP 1 Reply Last reply Reply Quote 0
                    • PeterJonesP
                      PeterJones @Lycan Thrope
                      last edited by

                      @lycan-thrope ,

                      My presumption, is that the Python Script is a fully contained solution

                      It is.

                      I only modifed and then cutout the section where the console class was, since you said to start fresh,

                      Cutting things out of code you don’t understand is not a good idea, unless you are able to get it back in just as easily as you take it out.

                      “Start fresh” was supposed to mean “start with the defaults”, not “delete everything, even stuff you didn’t write”.

                      The startup.py that I shared is the default machine startup.py, with a couple things added. But maybe that’s even too much to hope for right now.

                      Let’s start from scratch: download a portable Notepad++, and unzip to some other location than your normal Notepad++. Run that notepad++ (not as admin). Install PythonScript. Create a user startup.py (Plugins > Python Script > New Script, startup.py and it should default to trying to put it in ...\plugins\config\pythonscript\scripts
                      593c0e0a-d29f-42a6-8479-3ef137c26c6d-image.png

                      from Npp import *
                      
                      console.write("this is my portable _user_ startup.py\n")
                      console.show()
                      

                      Do not touch or edit the machine startup.py

                      3f3cd451-d931-4c8c-a20e-369225f32a8f-image.png

                      Lycan ThropeL 4 Replies Last reply Reply Quote 1
                      • Lycan ThropeL
                        Lycan Thrope @PeterJones
                        last edited by

                        @peterjones ,

                        Well, it appears the mucking about may have been the problem, but I came here right after it didn’t run, as is. Thank you, and now I have to figure out why it didn’t work as is, but at least I have a working example to learn from. I’m sorry if this is frustrating to you. It is to me, too. I try to follow exact directions when I do this stuff and for some reason, it sometimes doesn’t work as is. Mind you, after you help me get it going, when I pass it on to the community, I have to be able to answer as well, why something isn’t working when just following the standard install and running of the plugin.

                        Here’s your script pasted in, restarted, and the results:
                        AWorkingShot.PNG

                        And I always mean, thank you when I say it, and here’s the picture to say it:
                        ThanksPeter.PNG

                        Now the only thing I have to do, is figure out a different color scheme, and make sure it works for everyone that uses this, which means they’ll have to install PythonScript and all this good stuff, I have to know also. Thanks for always having the right answer, Peter.

                        Thank also to Michael and Eko for trying to help as well.

                        Lee

                        1 Reply Last reply Reply Quote 1
                        • Lycan ThropeL
                          Lycan Thrope @PeterJones
                          last edited by

                          @peterjones said in Call Tip Color change:

                          Cutting things out of code you don’t understand is not a good idea, unless you are able to get it back in just as easily as you take it out.
                          “Start fresh” was supposed to mean “start with the defaults”, not “delete everything, even stuff you didn’t write”.

                          I agree, Peter. When I got my first response, I was only adding to the stock file. The only thing I did, was uncomment the one section in the code that it said to to redirect the output, originally. That was it. It didn’t work, so proceeded to come here to show what was happening and get advice. I’m not the sharpest tack in the drawer, but I’d like to think I’m not the dull end either. :-)

                          Thanks again for your help.

                          Lee

                          1 Reply Last reply Reply Quote 0
                          • Lycan ThropeL
                            Lycan Thrope @PeterJones
                            last edited by

                            @peterjones ,

                            Just so we’re clear, if you look at one of my original posts way up there, this is the only section I changed, according to the instructions in the comment section it’s in:

                            # In order to set the stdout to the current active document, uncomment the following line
                            # sys.stdout = editor
                            # So print "hello world", will insert "hello world" at the current cursor position
                            
                            

                            This NOT working, is what prompted me to then comment out:

                            sys.stdout = console
                            

                            My erroneous assumption being that if you want it to go the editor and not the console, you have to comment out the other, but as you can see, I was trying just trying to get the file to do what the comments indicated I should do for a certain response. Maybe I read, too much? :-)

                            Lee

                            PeterJonesP 1 Reply Last reply Reply Quote 0
                            • Lycan ThropeL
                              Lycan Thrope @Ekopalypse
                              last edited by

                              @ekopalypse
                              For future reference, it’s at the bottom of the file in:
                              /Program Files/Notepad++/plugins/PythonScript/doc/usage.html at the bottom a paragraph or two just above the Startup section. :-)

                              Lee

                              1 Reply Last reply Reply Quote 0
                              • Lycan ThropeL
                                Lycan Thrope @PeterJones
                                last edited by

                                @peterjones
                                I’m going to follow your examples here, as well, for educational purposes, and again, I thank you for this breakdown.

                                My purpose for wanting to put it into the machine startup.py, is to streamline the installation and use of this enhancement for our UDL/FunctionList/AutoCompletion package so it’s not an involved process for. less technical users. I’m putting together an install package to try and automate the installation of the dBASE Plus package into NPP. If it’s included in the machine startup, then I can copy the file needed and that’s that. Perhaps, I can do it another way, with your examples above so it doesn’t mess with the standard settings and only adds the additional ability.

                                Not everyone is brave enough to admit, they don’t know what they’re doing and trying to understand outside of their comfort zone, how to do things. I’m just dumb enough to be more concerned with how to make things work than any illusory pride.
                                Lee

                                1 Reply Last reply Reply Quote 0
                                • Lycan ThropeL
                                  Lycan Thrope @PeterJones
                                  last edited by

                                  @peterjones ,

                                  Your example works perfectly, so that means I can create a user script and install it in that directory and it will start for the user after they start the PythonScript plugin. I only need to see if there is a way to set the default startup to ATSTARTUP and we’re good. This way, it’ll do it with minimal intervention of the user. Right?

                                  Lee

                                  1 Reply Last reply Reply Quote 0
                                  • PeterJonesP
                                    PeterJones @Lycan Thrope
                                    last edited by PeterJones

                                    @lycan-thrope said in Call Tip Color change:

                                    This NOT working, is what prompted me to then comment out:
                                    …

                                    I do not understand your logic here at all.

                                    You never have a print "hello world" or any other print statement anywhere in your startup.py, so I am not sure why you think it’s not printing where you want. You literally aren’t printing anywhere, and that’s why it’s not printing.

                                    My erroneous assumption being that if you want it to go the editor and not the console, you have to comment out the other,

                                    When it says print "hello world" will go to the editor instead of the console, that means that print statements willl put their output in whichever editor happens to be active, instead of putting their output in the console. That seems like a bad idea to me. PythonScript should generally use the editor or console objects themselves to writing to the active editors, not a generic python print statement.

                                    console.write() will always go the console, regardless of the sys.stdout override in the startup.py.

                                    My purpose for wanting to put it into the machine startup.py

                                    I am not sure that I see that overwriting c:\program files\notepad++\plugins\python script\scripts\startup.py is any more difficult than adding a new %AppData%\Notepad++\plugins\config\python script\scripts\startup.py [assuming normal installation, not portable] – from either your perspective or theirs. But if you think there’s a complexity difference, I guess that’s all that matters. Just make sure, if you do, that you include all the default setup (ie, the normal contents of startup.py), and don’t go deleting things unless you know exactly why.

                                    I only need to see if there is a way to set the default startup to ATSTARTUP and we’re good.

                                    That setting is stored on a per-user basis in %AppData%\Notepad++\plugins\config\PythonScriptStartup.cnf, as the line SETTING/STARTUP/ATSTARTUP vs SETTING/STARTUP/LAZY

                                    So if you want to default your users to that, then you will need to change that file for the user. Which means you are already writing to the AppData hierarchy, so that means that you might as well write to the AppData startup.py, not the machine startup.py.

                                    [*: This assumes a normal installation with AppData. If you are giving users a portable edition, then it’s at <portablefolder>\plugins\config\python script\scripts\startup.py and <portablefolder>\plugins\config\PythonScriptStartup.cnf]

                                    Lycan ThropeL 1 Reply Last reply Reply Quote 1
                                    • Lycan ThropeL
                                      Lycan Thrope @PeterJones
                                      last edited by

                                      @peterjones said in Call Tip Color change:

                                      You never have a print “hello world” or any other print statement anywhere in your startup.py, so I am not sure why you think it’s not printing where you want. You literally aren’t printing anywhere, and that’s why it’s not printing.

                                      That would explain the original confusion on my part. I thought it meant if I typed in the console (where the typed message was showing up) that if I wanted it to go to the document from the console, that was what I should have done. Mind you, I started by reading the startup.py, usually there are notes to read and I erroneously thought it was instructing me what to do to test it. My error.

                                      In the later message, I agree with you that a separate file in the user directory would suffice to other than change the ATSTARTUP this would help avoid user interaction. Not to detract from our users, but the less moving parts, the better. I’ve already been handling enough questions, myself about UDL collisions, this request for Calltip, etc, and again, if doing this UDL package for dBASE was easy enough, someone other than I would have done it already. :-)

                                      I’ve already written an installation script that may to the install already, but want to test it on a virgin copy of an AppData installed version, so I’ll be backing my stuff up and uninstalling to try out the first part of the package first to make sure it installs it without problems. After that, I’ll have to set it up so if they have a portable version, it can be installed to the directory of their choice and then all the files will be installed into the respective directories at that location.

                                      I’m researching other aspects, and will have to trial and error to make sure if I include these other options, I can write the instructions for installing say, the PythonScript themselves or see if my installation can do it, to minimize any issues with getting it up and functional. That’s why I was asking, and why I’m even looking at doing things that aren’t my strengths, since I’ve been on a constant learning curve since starting this project almost 3 months ago. For a 65 year old, learning new things isn’t as easy as it was 45 years ago. :-)

                                      Lee

                                      Lycan ThropeL 1 Reply Last reply Reply Quote 1
                                      • Lycan ThropeL
                                        Lycan Thrope @Lycan Thrope
                                        last edited by

                                        @lycan-thrope
                                        Forgot to mention, I may be the younger member, too. :-)

                                        We actually have a developer that’s in his 90’s…and another in his 80’s, so since I’m the young one that isn’t actively working, I figured it would make a nice side hobby to setup the NPP package since many have been asking if one exists, and many said if there was, they’d like to know where it is. :-)

                                        Of course, the main reason everyone says they haven’t gotten doing it is time…and that’s about all I have to offer since retiring. :-)

                                        Lee

                                        1 Reply Last reply Reply Quote 1
                                        • First post
                                          Last post
                                        The Community of users of the Notepad++ text editor.
                                        Powered by NodeBB | Contributors