Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Marking And Highlighting shortcut

    General Discussion
    2
    8
    6800
    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.
    • Harpreet Singh Bassan
      Harpreet Singh Bassan last edited by

      Is it possible to create my own shortcuts for Marking And or Highlighting any text with any style or just as standard style 1. By pressing the same should Clear it.
      Or Notepad++ can add it as standard of its own because they know what shortcuts are free.
      Thanks,

      Claudia Frank 1 Reply Last reply Reply Quote 0
      • Claudia Frank
        Claudia Frank @Harpreet Singh Bassan last edited by

        @Harpreet-Singh-Bassan

        By pressing the same should Clear it

        If this requirement needs to be fulfilled, then no, not with builtin features.

        Otherwise use shortcut mapper and style configurator.

        Cheers
        Claudia

        1 Reply Last reply Reply Quote 0
        • Harpreet Singh Bassan
          Harpreet Singh Bassan last edited by

          I would like this request to be fulfilled please. I use it for programming Galil servo controllers instead of using their editor. It will be very handy to add these marking and highlighting feature with shortcut.

          Claudia Frank 1 Reply Last reply Reply Quote 0
          • Claudia Frank
            Claudia Frank @Harpreet Singh Bassan last edited by

            @Harpreet-Singh-Bassan

            to get this solved now, I would recommend to use plugins like python/lua script to do it.
            Maybe someday npp supports it natively.

            Cheers
            Claudia

            1 Reply Last reply Reply Quote 0
            • Harpreet Singh Bassan
              Harpreet Singh Bassan last edited by

              O man. Thanks for some solutions at this time. BBBut both these two languages are the one I never have tried. Are there any example codes on line which I can just change little bit and do it. The latest one i have tried is Java but that too i am not as good. Or do you mind ----- please thro some codes here. Actually this will also the first time I will use any script in Notepad++. So how will I run script in Notepad++ . That will be a great help.

              Claudia Frank 1 Reply Last reply Reply Quote 0
              • Claudia Frank
                Claudia Frank @Harpreet Singh Bassan last edited by

                @Harpreet-Singh-Bassan

                what languages do you prefer?
                There are other possible solutions like c# …

                For python you need to install the python script plugin.
                I would propose to use the MSI package instead of using the plugin manager.

                First steps are described here .

                An example script would be

                import re                                                                           # needed to find whole words only
                                                                                                     
                editor.indicSetStyle(13,INDICATORSTYLE.STRAIGHTBOX)                                 # used to color selected text
                editor.indicSetFore(13,(255,0,0))                                                   # the color in RGB color syntax           
                editor.indicSetAlpha(13,155)                                                        # alpha settings
                editor.indicSetOutlineAlpha(13,255)                                                 # outlining
                editor.indicSetUnder(13,True)                                                       # draw under the text
                 
                # -----------------------------------------------------------------------------      
                
                _g = globals()                                                                      # global variable used to check status
                if not _g.get('CUSTOM_STYLER_IS_RUNNING'):                                          # if variable not defined yet,
                    CUSTOM_STYLER_IS_RUNNING = False                                                # set it to False (=NOT RUNNING)
                                                                                                    
                # -----------------------------------------------------------------------------      
                                                                                                     
                def clear_indicators():                                                             # used to clear coloring
                    text_end_position = editor.getLength()                                          # determine document length
                    editor.setIndicatorCurrent(13)                                                  # set defined indicator
                    editor.indicatorClearRange(0, text_end_position)                                # and clear it from whole document.
                                                                                                     
                # -----------------------------------------------------------------------------      
                                                                                                     
                def colorize(text):                                                                 # used to color the selected chars
                    matches = []                                                                    # create empty list of matches
                    editor.research('\\b{0}\\b'.format(text), lambda m: matches.append(m.span(0)))  # find selected chars and append it to match list
                                                                                                     
                    for match in matches:                                                           # for each match found
                        editor.setIndicatorCurrent(13)                                              # set the defined indicator and
                        editor.indicatorFillRange(match[0], match[1] - match[0])                    # color it.
                                                                                                     
                # -----------------------------------------------------------------------------      
                                                                                                     
                def main():                                                                         # main function to handle start/stop behavior
                    global CUSTOM_STYLER_IS_RUNNING                                                 # assining to global variable
                    if CUSTOM_STYLER_IS_RUNNING:                                                    # if script is currently running
                        clear_indicators()                                                          # clear all inidcators and
                        CUSTOM_STYLER_IS_RUNNING = False                                            # set flag to False
                    else:                                                                           # else
                        selected_text = editor.getSelText()                                         # get selected text
                        if len(selected_text) > 0 and selected_text.isspace() == False:             # if there is at least on char selected
                            CUSTOM_STYLER_IS_RUNNING = True                                         # set the flag to true and
                            colorize(selected_text)                                                 # color the selection.
                                                                                                     
                # ----------------------------------------------------------------------------- 
                                                                                                  
                main()                                                                              # entry point 
                

                Other python scripts can be found here or in this forum.

                Cheers
                Claudia

                1 Reply Last reply Reply Quote 0
                • Harpreet Singh Bassan
                  Harpreet Singh Bassan last edited by

                  Thanks Claudia. I use only cnc, plc, hmi, servo system programming the most. Other languages like C and visual basic are history for me. Java being new I still will prefer that. I use Eclipse for it. Any code help will be appreciated as otherwise I always try to work around.

                  1 Reply Last reply Reply Quote 0
                  • Claudia Frank
                    Claudia Frank last edited by

                    Sorry, I’m not aware that there is an java automation plugin available.
                    So, maybe you wanna give the python example a try?

                    Cheers
                    Claudia

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    Copyright © 2014 NodeBB Forums | Contributors