Using enum values

  • Mike Cowperthwaite

    I want to use Notepad.menuCommand() and Notepad.setStatusBar() methods:
    - menuCommand(), I can hardcode integers but would prefer symbolic access.

    - setStatusBar(), I can't get to work at all; from the console, I get:

        ArgumentError: Python argument types in Notepad.setStatusBar(Notepad, int, str) did not match C++ signature:
        setStatusBar(class NotepadPlusWrapper {lvalue}, enum StatusBarSection, char const *)

    Not sure if that error is because of using an int instead of an enum, or something else.

    I don't know how to access these enum values as symbols. Can you explain? Thanks.

  • Mike Cowperthwaite

    You're right, it is an enum, as the error kinda hints towards.  The enum is simply STATUSBARSECTION (the uppercase variant of the C++ version mentioned in the error).
    The enum is defined in the Npp module, which is automatically imported into __main__ (i.e. the "area" for the console and any script that is run).  However, if you're using it from a module you're importing, you'll need to import Npp, and use Npp.STATUSBARSECTION.  help(STATUSBARSECTION) from the console will give you the options.

    Sadly, there's a bug in the unicode translation of the text in 0.7.  That's fixed in the next release - which I'm really hoping will get released next week sometime - I'm away for a few days from tomorrow, so I know it won't be till probably next weekend.  If I get chance tonight, I'll upload a test version for you, with the fix in.

    For menuCommand, use the MENUCOMMAND enum -

    Again, help(MENUCOMMAND) will show you the options.  For both enums, all the options are listed in the help.

  • Mike Cowperthwaite

    I guess that the bug mentioned is where something like  setStatusBar(STATUSBARSECTION.DOCTYPE, "Hi mom!") yields some Chinese characters in the field.

    Is there (or could there be added) a way to retrieve the current text from the section, so I can restore it when I no longer need it?

  • Dave Brotherstone

    Thanks for posting.  Sorry a long work day meant I didn't get chance to finish a test version.  The other parts of it are still not quite ready. 

    I don't think there's an API call to "get" the current text from the section.  Should be an easy patch to submit though (to Notepad++), then it's just a matter of it being accepted and integrated.



Log in to post a comment.