• Login
Community
  • Login

Marking And Highlighting shortcut

Scheduled Pinned Locked Moved General Discussion
8 Posts 2 Posters 9.1k 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.
  • H
    Harpreet Singh Bassan
    last edited by Jun 30, 2016, 5:24 PM

    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,

    C 1 Reply Last reply Jun 30, 2016, 11:56 PM Reply Quote 0
    • C
      Claudia Frank @Harpreet Singh Bassan
      last edited by Jun 30, 2016, 11:56 PM

      @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
      • H
        Harpreet Singh Bassan
        last edited by Jul 5, 2016, 12:11 PM

        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.

        C 1 Reply Last reply Jul 5, 2016, 9:42 PM Reply Quote 0
        • C
          Claudia Frank @Harpreet Singh Bassan
          last edited by Jul 5, 2016, 9:42 PM

          @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
          • H
            Harpreet Singh Bassan
            last edited by Jul 6, 2016, 11:38 AM

            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.

            C 1 Reply Last reply Jul 6, 2016, 10:51 PM Reply Quote 0
            • C
              Claudia Frank @Harpreet Singh Bassan
              last edited by Jul 6, 2016, 10:51 PM

              @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
              • H
                Harpreet Singh Bassan
                last edited by Jul 7, 2016, 12:44 PM

                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
                • C
                  Claudia Frank
                  last edited by Jul 7, 2016, 10:35 PM

                  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
                  3 out of 8
                  • First post
                    3/8
                    Last post
                  The Community of users of the Notepad++ text editor.
                  Powered by NodeBB | Contributors