• Login
Community
  • Login

Display Descriptions of A Selected Keyword

Scheduled Pinned Locked Moved General Discussion
3 Posts 3 Posters 415 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.
  • L
    Long Chang
    last edited by Nov 3, 2020, 5:46 PM

    How can I add a method to show some descriptions when user select a keyword? e.g. when user select keyword “int”, there could be a textbox below shows "Integer -32,768 to 32,767 ".

    P 1 Reply Last reply Nov 3, 2020, 8:51 PM Reply Quote 0
    • P
      PeterJones @Long Chang
      last edited by Nov 3, 2020, 8:51 PM

      @Long-Chang ,

      There is no option in native Notepad++ to do this.

      One could write a plugin to do it. Or one could use a scripting plugin, like PythonScript, to do it. But the one who wrote the plugin or script would have to supply all the data (the map of keywords to information about the keyword).

      I don’t know how to make a popup in the scripting languages, and have never written a plugin, so I cannot help you with either of those.

      However, in the past I have shared scripts like this one that change the status bar to show information based on the current selection: you could alias a script similar to that one to the keyboard shortcut of your choice, and have it perform a lookup for keyword=>description, then change the status bar to the description.

      1 Reply Last reply Reply Quote 0
      • E
        Ekopalypse
        last edited by Ekopalypse Nov 3, 2020, 9:50 PM Nov 3, 2020, 9:49 PM

        @Long-Chang said in Display Descriptions of A Selected Keyword:

        Integer -32,768 to 32,767

        Are you looking for something like this

        88b12277-2915-4d05-b1ef-b363d59efce0-image.png

        from Npp import editor, SCINTILLANOTIFICATION, UPDATE
        
        suggestion_dict = {'int': 'Integer -32,768 to 32,767'}
        
        def on_select(args):
            if args['updated'] & UPDATE.SELECTION:
                x = suggestion_dict.get(editor.getCurrentWord(), None)
                if x: editor.callTipShow(editor.getCurrentPos(), x)
        
        # editor.clearCallbacks([ SCINTILLANOTIFICATION.UPDATEUI ])
        editor.callbackSync(on_select, [ SCINTILLANOTIFICATION.UPDATEUI ])
        

        Needs the pythonscript plugin to be installed.

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