Community
    • Login

    Change History markers

    Scheduled Pinned Locked Moved General Discussion
    16 Posts 4 Posters 1.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.
    • richluxR
      richlux @Alan Kilborn
      last edited by

      @Alan-Kilborn Thanks. I’ll have to look into doing this.

      Rich

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

        @richlux

        Have a look at Changed Lines. This may help if you just want to change colors.

        Cheers.

        1 Reply Last reply Reply Quote 1
        • Alan KilbornA
          Alan Kilborn
          last edited by Alan Kilborn

          …colors can be customized?

          Here’s a demo script that shows how it can be done, for one of the colors:

          # -*- coding: utf-8 -*-
          
          from Npp import *
          
          RGB_TUPLE = (255, 0, 0)
          
          SC_MARKNUM_HISTORY_REVERTED_TO_ORIGIN   = 21
          SC_MARKNUM_HISTORY_SAVED                = 22
          SC_MARKNUM_HISTORY_MODIFIED             = 23
          SC_MARKNUM_HISTORY_REVERTED_TO_MODIFIED = 24
          
          editor.markerSetBack(SC_MARKNUM_HISTORY_MODIFIED, RGB_TUPLE)
          editor.markerSetFore(SC_MARKNUM_HISTORY_MODIFIED, RGB_TUPLE)
          

          For more info on scripting in general see the FAQ entry for it.

          richluxR 2 Replies Last reply Reply Quote 3
          • richluxR
            richlux @Alan Kilborn
            last edited by

            @Alan-Kilborn Thank you so much for this sample. It is very helpful. I’m going to submit a feature request to see if they will add this as a setting that can be changed.

            Rich

            1 Reply Last reply Reply Quote 3
            • richluxR
              richlux @Alan Kilborn
              last edited by

              @Alan-Kilborn That worked great. Can you tell me what I need to put in the startup.py to have this script file run at startup automatically?

              Rich

              Alan KilbornA 1 Reply Last reply Reply Quote 0
              • Alan KilbornA
                Alan Kilborn @richlux
                last edited by

                @richlux said in Change History markers:

                what I need to put in the startup.py to have this script file run at startup automatically?

                Let’s formalize the script a bit more, which will allow what you’re asking in a nice fashion.

                I’ll call the script ChangeHistoryColors.py and revise it thusly:

                # -*- coding: utf-8 -*-
                from __future__ import print_function
                
                #########################################
                #
                #  ChangeHistoryColors (CHC)
                #
                #########################################
                
                # references:
                #  https://community.notepad-plus-plus.org/topic/24309/change-history-markers
                
                #-------------------------------------------------------------------------------
                
                from Npp import *
                
                #-------------------------------------------------------------------------------
                
                class CHC(object):
                
                    def __init__(self):
                
                        RGB_TUPLE = (255, 0, 0)
                
                        SC_MARKNUM_HISTORY_REVERTED_TO_ORIGIN   = 21
                        SC_MARKNUM_HISTORY_SAVED                = 22
                        SC_MARKNUM_HISTORY_MODIFIED             = 23
                        SC_MARKNUM_HISTORY_REVERTED_TO_MODIFIED = 24
                
                        editor.markerSetBack(SC_MARKNUM_HISTORY_MODIFIED, RGB_TUPLE)
                        editor.markerSetFore(SC_MARKNUM_HISTORY_MODIFIED, RGB_TUPLE)
                
                #-------------------------------------------------------------------------------
                
                if __name__ == '__main__': CHC()
                

                Then, to embed a call to it in the startup (User) script, do this:

                import ChangeHistoryColors
                ChangeHistoryColors.CHC()
                
                richluxR 2 Replies Last reply Reply Quote 3
                • Alan KilbornA Alan Kilborn referenced this topic on
                • richluxR
                  richlux @Alan Kilborn
                  last edited by richlux

                  @Alan-Kilborn That works great. Thanks again for all your help. I actually modified your script a little so only changes since the last save are highlighted. Here’s the core of it in case someone else want’s to use it.

                  RGB_MODIFIED = (255, 0, 0)
                  RGB_SAVED = (228, 228, 228)
                  
                  SC_MARKNUM_HISTORY_REVERTED_TO_ORIGIN   = 21
                  SC_MARKNUM_HISTORY_SAVED                = 22
                  SC_MARKNUM_HISTORY_MODIFIED             = 23
                  SC_MARKNUM_HISTORY_REVERTED_TO_MODIFIED = 24
                  
                  editor.markerSetBack(SC_MARKNUM_HISTORY_MODIFIED, RGB_MODIFIED)
                  editor.markerSetFore(SC_MARKNUM_HISTORY_MODIFIED, RGB_MODIFIED)
                  
                  editor.markerSetBack(SC_MARKNUM_HISTORY_REVERTED_TO_ORIGIN, RGB_MODIFIED)
                  editor.markerSetFore(SC_MARKNUM_HISTORY_REVERTED_TO_ORIGIN, RGB_MODIFIED)
                  
                  editor.markerSetBack(SC_MARKNUM_HISTORY_REVERTED_TO_MODIFIED, RGB_MODIFIED)
                  editor.markerSetFore(SC_MARKNUM_HISTORY_REVERTED_TO_MODIFIED, RGB_MODIFIED)
                  
                  editor.markerSetBack(SC_MARKNUM_HISTORY_SAVED, RGB_SAVED)
                  editor.markerSetFore(SC_MARKNUM_HISTORY_SAVED, RGB_SAVED)
                  

                  Rich

                  1 Reply Last reply Reply Quote 2
                  • richluxR
                    richlux @Alan Kilborn
                    last edited by

                    @Alan-Kilborn I have one last question for you. Is there something that needs to be done to get the startup (User) script to run when NPP is started? It doesn’t seem to be running automatically. I can manually run it after I start NPP, but obviously that defeats the purpose of a startup script!

                    Thank,
                    Rich

                    Alan KilbornA 1 Reply Last reply Reply Quote 0
                    • Alan KilbornA
                      Alan Kilborn @richlux
                      last edited by

                      @richlux said in Change History markers:

                      Is there something that needs to be done to get the startup (User) script to run

                      Maybe THIS?

                      richluxR 1 Reply Last reply Reply Quote 1
                      • richluxR
                        richlux @Alan Kilborn
                        last edited by

                        @Alan-Kilborn said in Change History markers:

                        Maybe THIS?

                        That did it!

                        Thanks again,
                        Rich

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