NPPM_GETCURRENTVIEW vs NPPM_GETCURRENTSCINTILLA
-
Does NPPM_GETCURRENTVIEW supersede NPPM_GETCURRENTSCINTILLA with a simpler API (the older message being retained for compatibility), or are there cases where these two might not yield the same result? If they are different, what is the distinction between them?
Looking at the code (here and here), they test different things, even though it seems like those two tests would be expected to yield the same result. Likewise, the descriptions don’t use exactly the same words (“Retrieves the current Scintilla view” vs “Retrieves the current used view”), though they sound like they mean the same thing.
-
Does NPPM_GETCURRENTVIEW supersede NPPM_GETCURRENTSCINTILLA with a simpler API (the older message being retained for compatibility) ?
My impression is that you’ve discovered another example of what I’ve said elsewhere — namely, that the plugin API is not so much a coherent system as an append-only list of features accumulated over many years. From that perspective, the best answer you’re likely to get will come from the revision history.
Apart from cosmetic improvements to the documentation comments (
--ignore-rev bb278b26f), it does appear thatNPPM_GETCURRENTSCINTILLAcame first, although exactly when has been lost in the version control system’s translation from subversion to git (note the leading?s):$ git blame -L/NPPM_GETCURRENTSCINTILLA/,+6 --ignore-rev bb278b26f -- PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h ?4dd3b257e (Don Ho 2009-04-24 23:34:47 +0000 55) #define NPPM_GETCURRENTSCINTILLA (NPPMSG + 4) ?9cbd03c30 (LEONARDO SILVA 2022-02-23 13:51:58 -0300 56) // BOOL NPPM_GETCURRENTSCINTILLA(0, int* iScintillaView) ?4dd3b257e (Don Ho 2009-04-24 23:34:47 +0000 57) // Get current Scintilla view. ?a87e89ea9 (Don HO 2018-11-07 23:30:59 +0100 58) // wParam: 0 (not used) ?0f8d5724a (Shridhar Kumar 2022-04-26 22:32:24 -0400 59) // lParam[out]: iScintillaView could be 0 (Main View) or 1 (Sub View) ?4dd3b257e (Don Ho 2009-04-24 23:34:47 +0000 60) // return TRUEThe relatively more recent
NPPM_GETCURRENTVIEWAPI has existed without substantial revision since 2013.$ git blame -L/NPPM_GETCURRENTVIEW/,+6 --ignore-rev bb278b26f -- PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h d6ea29c577 (Don Ho 2013-03-03 01:04:09 +0000 697) #define NPPM_GETCURRENTVIEW (NPPMSG + 88) ?d6ea29c57 (Don Ho 2013-03-03 01:04:09 +0000 698) // int NPPM_GETCURRENTVIEW(0, 0) ?775d204ef (Don HO 2018-12-04 13:38:25 +0100 699) // Get the current used view. ?7874f8dab (Don HO 2020-11-19 04:29:50 +0100 700) // wParam: 0 (not used) ?7874f8dab (Don HO 2020-11-19 04:29:50 +0100 701) // lParam: 0 (not used) d6ea29c577 (Don Ho 2013-03-03 01:04:09 +0000 702) // Return: current edit view of Notepad++. Only 2 possible values: 0 = Main, 1 = SecondaryMake of that what you will. I would point only out that the documented return value of
NPPM_GETCURRENTSCINTILLAis not supported by the actual implementation; theFALSE-returning code path contradicts the statement that this API “Returns always True [sic]”. -
I would point only out that the documented return value of
NPPM_GETCURRENTSCINTILLAis not supported by the actual implementation; theFALSE-returning code path contradicts the statement that this API “Returns always True [sic]”.Technically so, though the
FALSEvalue only happens when the caller sends an invalid parameter (LPARAMnull, when it should be a pointer to anint). There’s also the additional result value of -1, which is documented, but which a comment in the code says “cannot happen”; the equivalent doesn’t exist in NPPM_GETCURRENTVIEW.What troubled me, though, was that the two calls base their responses on different things. I made some attempt to search the code. As best I could tell, the connection between
Notepad_plus::_pEditViewandNotepad_plus::_activeViewis… haphazard. Even though they sound like they represent the same information in different forms (an integer that represents the main or secondary view as 0 or 1, and a pointer to one of twoScintillaEditViewstructures that represent the main and secondary views), I can’t “prove” that they always change together. So I cannot be certain that they do not represent different information, used for different purposes.If NPPM_GETCURRENTVIEW were meant merely to supersede the older, clumsier-to-use NPPM_GETCURRENTSCINTILLA, one would expect it to have been based on the same code (if for no other reason, for clarity). I couldn’t find any explanation of why this call was created or what problem it was meant to solve. So I was hoping perhaps someone would know and remember the rationale for the newer call and/or the purposes of the two different variables on which the calls are based, and could tell me either “they’re the same thing, use whichever you like” or “here is the situation in which they can return different results.”
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login