From bf97e7ba72cb826f9111ec0dc1e599a5b0eb61b7 Mon Sep 17 00:00:00 2001 From: dail8859 Date: Thu, 15 Dec 2016 15:33:07 -0500 Subject: [PATCH] Add alot more N++ messages Related: #41 --- src/Npp/Notepad_plus_msgs.h | 2 +- src/NppIFaceTable.cpp | 44 ++++++++++++++++++++++++++++++------- src/SciTE/LuaExtension.cpp | 6 ++--- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/src/Npp/Notepad_plus_msgs.h b/src/Npp/Notepad_plus_msgs.h index 101757c..91d6ac1 100644 --- a/src/Npp/Notepad_plus_msgs.h +++ b/src/Npp/Notepad_plus_msgs.h @@ -240,7 +240,7 @@ enum winVer{ WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, W // Returns active Buffer #define NPPM_RELOADBUFFERID (NPPMSG + 61) - // VOID NPPM_RELOADBUFFERID(0, 0) + // BOOL NPPM_RELOADBUFFERID(INT bufferID, BOOL alertOrNot) // Reloads Buffer // wParam: Buffer to reload // lParam: 0 if no alert, else alert diff --git a/src/NppIFaceTable.cpp b/src/NppIFaceTable.cpp index 7492bbd..757e57f 100644 --- a/src/NppIFaceTable.cpp +++ b/src/NppIFaceTable.cpp @@ -486,12 +486,15 @@ static std::vector ifaceConstants = { { "L_XML", L_XML }, { "L_YAML", L_YAML }, { "MAIN_VIEW", MAIN_VIEW }, + { "MODELESSDIALOGADD", MODELESSDIALOGADD }, + { "MODELESSDIALOGREMOVE", MODELESSDIALOGREMOVE }, { "NPPM_GETAPPDATAPLUGINSALLOWED", NPPM_GETAPPDATAPLUGINSALLOWED }, { "NPPM_GETBUFFERLANGTYPE", NPPM_GETBUFFERLANGTYPE }, { "NPPM_GETCURRENTBUFFERID", NPPM_GETCURRENTBUFFERID }, { "NPPM_GETCURRENTCOLUMN", NPPM_GETCURRENTCOLUMN }, { "NPPM_GETCURRENTLANGTYPE", NPPM_GETCURRENTLANGTYPE }, { "NPPM_GETCURRENTLINE", NPPM_GETCURRENTLINE }, + { "NPPM_GETCURRENTNATIVELANGENCODING", NPPM_GETCURRENTNATIVELANGENCODING }, { "NPPM_GETCURRENTVIEW", NPPM_GETCURRENTVIEW }, { "NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR", NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR }, { "NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR", NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR }, @@ -504,6 +507,12 @@ static std::vector ifaceConstants = { { "NPPM_SETCURRENTLANGTYPE", NPPM_SETCURRENTLANGTYPE }, { "NPPM_SETEDITORBORDEREDGE", NPPM_SETEDITORBORDEREDGE }, { "PRIMARY_VIEW", PRIMARY_VIEW }, + { "STATUSBAR_CUR_POS", STATUSBAR_CUR_POS }, + { "STATUSBAR_DOC_SIZE", STATUSBAR_DOC_SIZE }, + { "STATUSBAR_DOC_TYPE", STATUSBAR_DOC_TYPE }, + { "STATUSBAR_EOF_FORMAT", STATUSBAR_EOF_FORMAT }, + { "STATUSBAR_TYPING_MODE", STATUSBAR_TYPING_MODE }, + { "STATUSBAR_UNICODE_TYPE", STATUSBAR_UNICODE_TYPE }, { "SECOND_VIEW", SECOND_VIEW }, { "SUB_VIEW", SUB_VIEW }, { "WV_95", WV_95 }, @@ -525,7 +534,9 @@ static std::vector ifaceConstants = { static std::vector ifaceFunctions = { { "ActivateDoc", NPPM_ACTIVATEDOC, iface_void, { iface_int, iface_int } }, + { "DocSwitcherDisableColumn", NPPM_DOCSWITCHERDISABLECOLUMN, iface_void, { iface_void, iface_bool } }, { "DoOpen", NPPM_DOOPEN, iface_bool, { iface_void, iface_tstring } }, + { "DmmViewOtherTab", NPPM_DMMVIEWOTHERTAB, iface_void, { iface_void, iface_tstring } }, { "GetBufferIDFromPos", NPPM_GETBUFFERIDFROMPOS, iface_int, { iface_int, iface_int } }, { "GetCurrentDirectory", NPPM_GETCURRENTDIRECTORY, iface_void, { iface_length, iface_tstringresult } }, { "GetCurrentDocIndex", NPPM_GETCURRENTDOCINDEX, iface_int, { iface_void, iface_int } }, @@ -533,24 +544,39 @@ static std::vector ifaceFunctions = { { "GetExtPart", NPPM_GETEXTPART, iface_void, { iface_length, iface_tstringresult } }, { "GetFileName", NPPM_GETFILENAME, iface_void, { iface_length, iface_tstringresult } }, { "GetFullCurrentPath", NPPM_GETFULLCURRENTPATH, iface_void, { iface_length, iface_tstringresult } }, + { "GetFullPathFromBufferID", NPPM_GETFULLPATHFROMBUFFERID, iface_void, { iface_int, iface_tstringresult} }, { "GetNamePart", NPPM_GETNAMEPART, iface_void, { iface_length, iface_tstringresult } }, { "GetNbOpenFiles", NPPM_GETNBOPENFILES, iface_int, { iface_void, iface_int } }, + { "GetNbSessionFiles", NPPM_GETNBSESSIONFILES, iface_int, { iface_void, iface_tstring } }, { "GetNppDirectory", NPPM_GETNPPDIRECTORY, iface_void, { iface_length, iface_tstringresult } }, { "GetNppFullFilePath", NPPM_GETNPPFULLFILEPATH, iface_void, { iface_length, iface_tstringresult } }, { "GetPluginsConfigDir", NPPM_GETPLUGINSCONFIGDIR, iface_void, { iface_length, iface_tstringresult } }, - //{ "GetPosFromBufferID", NPPM_GETPOSFROMBUFFERID, iface_int, { iface_int, iface_int } }, - //{ "HideTabBar", NPPM_HIDETABBAR, iface_bool, { iface_void, iface_bool } }, - //{ "IsTabBarHidden", NPPM_ISTABBARHIDDEN, iface_bool, { iface_void, iface_void } }, - //{ "LaunchFindInFilesDlg", NPPM_LAUNCHFINDINFILESDLG, iface_void, { iface_tstring, iface_tstring } }, - //{ "LoadSession", NPPM_LOADSESSION, iface_void, { iface_void, iface_tstring } }, + { "GetPosFromBufferID", NPPM_GETPOSFROMBUFFERID, iface_int, { iface_int, iface_int } }, + { "HideMenu", NPPM_HIDEMENU, iface_bool, { iface_void, iface_bool } }, + { "HideStatusBar", NPPM_HIDESTATUSBAR, iface_bool, { iface_void, iface_bool } }, + { "HideTabBar", NPPM_HIDETABBAR, iface_bool, { iface_void, iface_bool } }, + { "HideToolBar", NPPM_HIDETOOLBAR, iface_bool, { iface_void, iface_bool } }, + { "IsDocSwitcherShown", NPPM_ISDOCSWITCHERSHOWN, iface_bool, { iface_void, iface_void } }, + { "IsMenuHidden", NPPM_ISMENUHIDDEN, iface_bool, { iface_void, iface_void } }, + { "IsStatusBarHidden", NPPM_ISSTATUSBARHIDDEN, iface_bool, { iface_void, iface_void } }, + { "IsTabBarHidden", NPPM_ISTABBARHIDDEN, iface_bool, { iface_void, iface_void } }, + { "IsToolBarHidden", NPPM_ISTOOLBARHIDDEN, iface_bool, { iface_void, iface_void } }, + { "LaunchFindInFilesDlg", NPPM_LAUNCHFINDINFILESDLG, iface_void, { iface_tstring, iface_tstring} }, + { "LoadSession", NPPM_LOADSESSION, iface_void, { iface_void, iface_tstring } }, + { "MakeCurrentBufferDirty", NPPM_MAKECURRENTBUFFERDIRTY, iface_void, { iface_void, iface_void } }, { "MenuCommand", NPPM_MENUCOMMAND, iface_void, { iface_void, iface_int } }, + { "ReloadBufferID", NPPM_RELOADBUFFERID, iface_bool, { iface_int, iface_bool } }, { "ReloadFile", NPPM_RELOADFILE, iface_int, { iface_bool, iface_tstring } }, { "SaveAllFiles", NPPM_SAVEALLFILES, iface_bool, { iface_void, iface_void } }, { "SaveCurrentFile", NPPM_SAVECURRENTFILE, iface_bool, { iface_void, iface_void } }, { "SaveCurrentFileAs", NPPM_SAVECURRENTFILEAS, iface_bool, { iface_bool, iface_tstring } }, - { "SaveFile", NPPM_SAVEFILE, iface_void, {iface_void, iface_tstring} }, - //{ "SaveCurrentSession", NPPM_SAVECURRENTSESSION, iface_void, { iface_void, iface_tstring } }, + { "SaveCurrentSession", NPPM_SAVECURRENTSESSION, iface_void, { iface_void, iface_tstring } }, + { "SaveFile", NPPM_SAVEFILE, iface_void, { iface_void, iface_tstring} }, + { "SetEditorBorderEdge", NPPM_SETEDITORBORDEREDGE, iface_void, { iface_void, iface_bool} }, + { "SetSmoothFont", NPPM_SETSMOOTHFONT, iface_void, { iface_void, iface_bool} }, + { "ShowDocSwitcher", NPPM_SHOWDOCSWITCHER, iface_void, { iface_void, iface_bool} }, { "SwitchToFile", NPPM_SWITCHTOFILE, iface_bool, { iface_void, iface_tstring } }, + { "TriggerTabbarContextMenu", NPPM_TRIGGERTABBARCONTEXTMENU, iface_void, { iface_int, iface_int } }, }; static std::vector ifaceProperties = { @@ -558,13 +584,15 @@ static std::vector ifaceProperties = { { "BufferLangType", NPPM_GETBUFFERLANGTYPE, NPPM_SETBUFFERLANGTYPE, iface_int, iface_int }, { "CurrentBufferID", NPPM_GETCURRENTBUFFERID, 0, iface_int, iface_void }, { "CurrentColumn", NPPM_GETCURRENTCOLUMN, 0, iface_position, iface_void }, - //{ "CurrentLangType", NPPM_GETCURRENTLANGTYPE, NPPM_SETCURRENTLANGTYPE, iface_int, iface_void }, + // { "CurrentLangType", NPPM_GETCURRENTLANGTYPE, NPPM_SETCURRENTLANGTYPE, iface_int, iface_void }, { "CurrentLine", NPPM_GETCURRENTLINE, 0, iface_int, iface_void }, { "CurrentView", NPPM_GETCURRENTVIEW, 0, iface_int, iface_void }, { "DefaultBackgroundColor", NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR, 0, iface_colour, iface_void }, { "DefaultForegroundColor", NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR, 0, iface_colour, iface_void }, { "LanguageDescription", NPPM_GETLANGUAGEDESC, 0, iface_tstringresult, iface_int }, { "LanguageName", NPPM_GETLANGUAGENAME, 0, iface_tstringresult, iface_int }, + { "NativeLangEncoding", NPPM_GETCURRENTNATIVELANGENCODING, 0, iface_int, iface_void }, + { "StatusBar", 0, NPPM_SETSTATUSBAR, iface_tstring, iface_int}, { "Version", NPPM_GETNPPVERSION, 0, iface_int, iface_void }, { "WindowsVersion", NPPM_GETWINDOWSVERSION, 0, iface_int, iface_void }, }; diff --git a/src/SciTE/LuaExtension.cpp b/src/SciTE/LuaExtension.cpp index ed3e5cc..8c5ca6e 100644 --- a/src/SciTE/LuaExtension.cpp +++ b/src/SciTE/LuaExtension.cpp @@ -985,7 +985,7 @@ static int iface_function_helper(lua_State *L, const IFaceFunction &func) { char *stringResult = 0; wchar_t *wstringResult = 0; - tstring nppstrparam; + tstring nppstrparams[2]; // 2 in case both params are tstrings enum stringResultType { none, string, tstring } needStringResult = none; int loopParamCount = 2; @@ -1011,8 +1011,8 @@ static int iface_function_helper(lua_State *L, const IFaceFunction &func) { params[i] = SptrFromString(s ? s : ""); } else if (func.paramType[i] == iface_tstring) { const char *s = lua_tostring(L, arg++); - nppstrparam = GUI::StringFromUTF8(s ? s : ""); - params[i] = reinterpret_cast(nppstrparam.c_str()); + nppstrparams[i] = GUI::StringFromUTF8(s ? s : ""); + params[i] = reinterpret_cast(nppstrparams[i].c_str()); } else if (func.paramType[i] == iface_keymod) { int keycode = static_cast(luaL_checkinteger(L, arg++)) & 0xFFFF; int modifiers = static_cast(luaL_checkinteger(L, arg++)) & (SCMOD_SHIFT|SCMOD_CTRL|SCMOD_ALT);