SourceForge has been redesigned. Learn more.
Close

Get keywords (reserved words) of current lang

Help
MMTsuchi
2012-03-21
2015-12-17
  • MMTsuchi

    MMTsuchi - 2012-03-21

    Hi,
    How could I get a list of keywords used by current language of an opened document ?
    I wish to test if a given word is in the list of keywords.

    I found "editor.describeKeyWordSets()"
    It returns only 'Keywords\nOperators\nAttributes\nStandard Functions\nStandard Packages\nStandard Types\nUser Words'

     
  • Dave Brotherstone

    Unfortunately there's no way to ask scintilla for the keyword list.  You could look it up in langs.xml though - it's not perfect as if it's just been changed (and N++ has not been restarted), then langs.xml won't reflect the real state of the keywords.

    Dave

     
  • MMTsuchi

    MMTsuchi - 2012-03-26

    Thanks for answer. I have copied/pasted those keywords in my script.

     
  • roymesi

    roymesi - 2015-12-17

    Is there a way to know when Scintilla found a keyword (in NPP)?
    I mean, I want to know when I click a reserved keyword, that Scintilla used it from the list (for a plugin I'm writing for NPP).
    Thx.

     
    • Dave Brotherstone

      Sadly that's a bit of a mess in scintilla as far as I know. You can look at
      the style of the clicked word, which gives you a single byte number. This
      number corresponds to some identified content, e.g. some "language
      element". These styles are different across the different lexers, e.g.
      style 1 might be a keyword in the C++ lexer, but might be a method in the
      JavaScript lexer.

      Basically, you'd need a map of lexer to keyword style, which you can get by
      looking at the lexer information - I think there's a file somewhere with
      the style names for each lexer, even though it might not be complete. Ask
      on the scintilla mailing list if you can't find the info you need.

      On Thu, 17 Dec 2015 08:11 roymesi roymesi2@users.sf.net wrote:

      Is there a way to know when Scintilla found a keyword (in NPP)?
      I mean, I want to know when I click a reserved keyword, that Scintilla
      used it from the list (for a plugin I'm writing for NPP).
      Thx.


      Get keywords (reserved words) of current lang


      Sent from sourceforge.net because you indicated interest in <
      https://sourceforge.net/p/npppythonscript/discussion/1188886/>

      To unsubscribe from further messages, please visit <
      https://sourceforge.net/auth/subscriptions/>

       

Log in to post a comment.