Skip to content

Commit

Permalink
- added appveyor.yml with preparation for automatic github deloyment,…
Browse files Browse the repository at this point in the history
… just release builds are possible by available nmake makefile

- updated npp include files to v3.1 from https://github.com/npp-plugins/plugintemplate, modified PluginInterface.h to include menuCmdID.h as before
- changed makefile for x64 build
- updated bufferid references from INT -> LRESULT
- fixed issue https://notepad-plus-plus.org/community/topic/12558/session-manager-issue by usage of fix from https://github.com/pnedev/npp-session-manager
  • Loading branch information
chcg committed Jun 27, 2018
1 parent 407cded commit aff025b
Show file tree
Hide file tree
Showing 10 changed files with 264 additions and 87 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ X=src\xml

# http://msdn.microsoft.com/en-us/library/fwkeyyhe.aspx
CXX=cl
CXXFLAGS=/O2 /EHs /GR- /MT /nologo /W3 /WX- /Gd /Gm- /Fo$O\ /fp:fast /wd4995 \
CXXFLAGS=/O2 /EHs /GR- /MT /nologo /W3 /WX- /Gd /Gm- /Fo$O\ /fp:fast \
/errorReport:none /Zc:wchar_t /DWIN32 /DNDEBUG /D_WINDOWS /D_USRDLL \
/D_WINDLL /DUNICODE /D_UNICODE /c

# http://msdn.microsoft.com/en-us/library/y0zzbyt4.aspx
LD=link
LIBS=user32.lib shell32.lib
LDFLAGS=/DLL /nologo /OUT:$O\$(PRJ).dll /INCREMENTAL:NO /MANIFEST:NO \
/MACHINE:X86 /ERRORREPORT:NONE
/ERRORREPORT:NONE

RC=rc
RCFLAGS=/nologo /fo$O\$(PRJ).res
Expand Down
48 changes: 48 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version: 1.4.2.{build}
image: Visual Studio 2017

environment:
matrix:
- configuration: Release

platform:
- x64
- x86

install:
- if "%platform%"=="x64" set archi=amd64
- if "%platform%"=="x86" set archi=x86
- call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %archi%

build:
parallel: true
verbosity: minimal

build_script:
- cd "%APPVEYOR_BUILD_FOLDER%"
- nmake

after_build:
- cd "%APPVEYOR_BUILD_FOLDER%"
- ps: >-
Push-AppveyorArtifact "obj\SessionMgr.dll" -FileName SessionMgr.dll
if ($($env:APPVEYOR_REPO_TAG) -eq "true") {
$ZipFileName = "SessionMgr_$($env:APPVEYOR_REPO_TAG_NAME)_$env:PLATFORM.zip"
7z a $ZipFileName "obj\SessionMgr.dll"
}
artifacts:
- path: SessionMgr_*.zip
name: releases

deploy:
provider: GitHub
auth_token:
secure: !!TODO, see https://www.appveyor.com/docs/deployment/github/#provider-settings!!
artifact: releases
draft: false
prerelease: false
force_update: true
on:
appveyor_repo_tag: true
2 changes: 1 addition & 1 deletion src/DllMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ extern "C" __declspec(dllexport) void setInfo(NppData nppd)

extern "C" __declspec(dllexport) LPCWSTR getName()
{
return app_getName();
return PLUGIN_FULL_NAME;
}

extern "C" __declspec(dllexport) FuncItem* getFuncsArray(INT *pnbFuncItems)
Expand Down
2 changes: 1 addition & 1 deletion src/Properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ void updateSessionFromGlobal(LPWSTR sesFile)
/** Updates document properties from global file properties.
When an existing document is added to a session, its bookmarks and
firstVisibleLine are updated from the global properties. */
void updateDocumentFromGlobal(INT bufferId)
void updateDocumentFromGlobal(LRESULT bufferId)
{
LPSTR mbPathname;
WCHAR pathname[MAX_PATH];
Expand Down
2 changes: 1 addition & 1 deletion src/Properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace prp {

void updateGlobalFromSession(LPWSTR sesFile);
void updateSessionFromGlobal(LPWSTR sesFile);
void updateDocumentFromGlobal(INT bufferId);
void updateDocumentFromGlobal(LRESULT bufferId);

} // end namespace NppPlugin::prp

Expand Down
4 changes: 2 additions & 2 deletions src/SessionMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ vector<Session> _sessions; ///< stores info on sessions read from disk
INT _sesCurIdx; ///< current session index
INT _sesPrvIdx; ///< previous session index
INT _sesDefIdx; ///< default session index
INT _bidFileOpened; ///< bufferId from most recent NPPN_FILEOPENED
INT _bidBufferActivated; ///< XXX experimental. bufferId from most recent NPPN_BUFFERACTIVATED
LRESULT _bidFileOpened; ///< bufferId from most recent NPPN_FILEOPENED
LRESULT _bidBufferActivated; ///< XXX experimental. bufferId from most recent NPPN_BUFFERACTIVATED
bool _appReady; ///< if false, plugin should do nothing
bool _sesLoading; ///< if true, a session is loading
bool _fileOpenedFromCmdLine;
Expand Down
95 changes: 75 additions & 20 deletions src/npp/Notepad_plus_msgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
// version 2 of the License, or (at your option) any later version.
//
// Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a
// it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the
// following:
// following:
// 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield.
Expand All @@ -29,22 +29,26 @@
#ifndef NOTEPAD_PLUS_MSGS_H
#define NOTEPAD_PLUS_MSGS_H

#include <windows.h>
#include <tchar.h>

enum LangType {L_TEXT, L_PHP , L_C, L_CPP, L_CS, L_OBJC, L_JAVA, L_RC,\
L_HTML, L_XML, L_MAKEFILE, L_PASCAL, L_BATCH, L_INI, L_ASCII, L_USER,\
L_ASP, L_SQL, L_VB, L_JS, L_CSS, L_PERL, L_PYTHON, L_LUA,\
L_ASP, L_SQL, L_VB, L_JS, L_CSS, L_PERL, L_PYTHON, L_LUA, \
L_TEX, L_FORTRAN, L_BASH, L_FLASH, L_NSIS, L_TCL, L_LISP, L_SCHEME,\
L_ASM, L_DIFF, L_PROPS, L_PS, L_RUBY, L_SMALLTALK, L_VHDL, L_KIX, L_AU3,\
L_CAML, L_ADA, L_VERILOG, L_MATLAB, L_HASKELL, L_INNO, L_SEARCHRESULT,\
L_CMAKE, L_YAML, L_COBOL, L_GUI4CLI, L_D, L_POWERSHELL, L_R, L_JSP,\
L_COFFEESCRIPT,\
L_COFFEESCRIPT, L_JSON, L_JAVASCRIPT, L_FORTRAN_77,\
// Don't use L_JS, use L_JAVASCRIPT instead
// The end of enumated language type, so it should be always at the end
L_EXTERNAL};
enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV_S2003, WV_XPX64, WV_VISTA, WV_WIN7, WV_WIN8, WV_WIN81};

enum winVer{ WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV_S2003, WV_XPX64, WV_VISTA, WV_WIN7, WV_WIN8, WV_WIN81, WV_WIN10};


//Here you can find how to use these messages : http://notepad-plus.sourceforge.net/uk/plugins-HOWTO.php

//Here you can find how to use these messages : http://docs.notepad-plus-plus.org/index.php/Messages_And_Notifications
#define NPPMSG (WM_USER + 1000)

#define NPPM_GETCURRENTSCINTILLA (NPPMSG + 4)
Expand Down Expand Up @@ -76,7 +80,7 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV

#define NPPM_GETOPENFILENAMESPRIMARY (NPPMSG + 17)
#define NPPM_GETOPENFILENAMESSECOND (NPPMSG + 18)

#define NPPM_CREATESCINTILLAHANDLE (NPPMSG + 20)
#define NPPM_DESTROYSCINTILLAHANDLE (NPPMSG + 21)
#define NPPM_GETNBUSERLANG (NPPMSG + 22)
Expand All @@ -103,7 +107,7 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
//ascii file to unicode
//int NPPM_ENCODESCI(MAIN_VIEW/SUB_VIEW, 0)
//return new unicodeMode

#define NPPM_DECODESCI (NPPMSG + 27)
//unicode file to ascii
//int NPPM_DECODESCI(MAIN_VIEW/SUB_VIEW, 0)
Expand Down Expand Up @@ -162,7 +166,7 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
//HWND WM_DMM_GETPLUGINHWNDBYNAME(const TCHAR *windowName, const TCHAR *moduleName)
// if moduleName is NULL, then return value is NULL
// if windowName is NULL, then the first found window handle which matches with the moduleName will be returned

#define NPPM_MAKECURRENTBUFFERDIRTY (NPPMSG + 44)
//BOOL NPPM_MAKECURRENTBUFFERDIRTY(0, 0)

Expand All @@ -187,13 +191,13 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
// uncomment //#include "menuCmdID.h"
// in the beginning of this file then use the command symbols defined in "menuCmdID.h" file
// to access all the Notepad++ menu command items

#define NPPM_TRIGGERTABBARCONTEXTMENU (NPPMSG + 49)
//void NPPM_TRIGGERTABBARCONTEXTMENU(int view, int index2Activate)

#define NPPM_GETNPPVERSION (NPPMSG + 50)
// int NPPM_GETNPPVERSION(0, 0)
// return version
// return version
// ex : v4.6
// HIWORD(version) == 4
// LOWORD(version) == 6
Expand All @@ -213,26 +217,26 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
// Return VIEW|INDEX from a buffer ID. -1 if the bufferID non existing
// if priorityView set to SUB_VIEW, then SUB_VIEW will be search firstly
//
// VIEW takes 2 highest bits and INDEX (0 based) takes the rest (30 bits)
// VIEW takes 2 highest bits and INDEX (0 based) takes the rest (30 bits)
// Here's the values for the view :
// MAIN_VIEW 0
// SUB_VIEW 1

#define NPPM_GETFULLPATHFROMBUFFERID (NPPMSG + 58)
// INT NPPM_GETFULLPATHFROMBUFFERID(INT bufferID, TCHAR *fullFilePath)
// Get full path file name from a bufferID.
// Get full path file name from a bufferID.
// Return -1 if the bufferID non existing, otherwise the number of TCHAR copied/to copy
// User should call it with fullFilePath be NULL to get the number of TCHAR (not including the nul character),
// allocate fullFilePath with the return values + 1, then call it again to get full path file name

#define NPPM_GETBUFFERIDFROMPOS (NPPMSG + 59)
// INT NPPM_GETBUFFERIDFROMPOS(INT index, INT iView)
// LRESULT NPPM_GETBUFFERIDFROMPOS(INT index, INT iView)
// wParam: Position of document
// lParam: View to use, 0 = Main, 1 = Secondary
// Returns 0 if invalid

#define NPPM_GETCURRENTBUFFERID (NPPMSG + 60)
// INT NPPM_GETCURRENTBUFFERID(0, 0)
// LRESULT NPPM_GETCURRENTBUFFERID(0, 0)
// Returns active Buffer

#define NPPM_RELOADBUFFERID (NPPMSG + 61)
Expand Down Expand Up @@ -363,15 +367,15 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
// Get programing language name from the given language type (LangType)
// Return value is the number of copied character / number of character to copy (\0 is not included)
// You should call this function 2 times - the first time you pass langName as NULL to get the number of characters to copy.
// You allocate a buffer of the length of (the number of characters + 1) then call NPPM_GETLANGUAGENAME function the 2nd time
// You allocate a buffer of the length of (the number of characters + 1) then call NPPM_GETLANGUAGENAME function the 2nd time
// by passing allocated buffer as argument langName

#define NPPM_GETLANGUAGEDESC (NPPMSG + 84)
// INT NPPM_GETLANGUAGEDESC(int langType, TCHAR *langDesc)
// Get programing language short description from the given language type (LangType)
// Return value is the number of copied character / number of character to copy (\0 is not included)
// You should call this function 2 times - the first time you pass langDesc as NULL to get the number of characters to copy.
// You allocate a buffer of the length of (the number of characters + 1) then call NPPM_GETLANGUAGEDESC function the 2nd time
// You allocate a buffer of the length of (the number of characters + 1) then call NPPM_GETLANGUAGEDESC function the 2nd time
// by passing allocated buffer as argument langDesc

#define NPPM_SHOWDOCSWITCHER (NPPMSG + 85)
Expand Down Expand Up @@ -403,6 +407,17 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
// INT NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR(0, 0)
// Return: current editor default background color. You should convert the returned value in COLORREF

#define NPPM_SETSMOOTHFONT (NPPMSG + 92)
// VOID NPPM_SETSMOOTHFONT(0, BOOL setSmoothFontOrNot)

#define NPPM_SETEDITORBORDEREDGE (NPPMSG + 93)
// VOID NPPM_SETEDITORBORDEREDGE(0, BOOL withEditorBorderEdgeOrNot)

#define NPPM_SAVEFILE (NPPMSG + 94)
// VOID NPPM_SAVEFILE(0, const TCHAR *fileNameToSave)

#define NPPM_DISABLEAUTOUPDATE (NPPMSG + 95) // 2119 in decimal
// VOID NPPM_DISABLEAUTOUPDATE(0, 0)

#define RUNCOMMAND_USER (WM_USER + 3000)
#define NPPM_GETFULLCURRENTPATH (RUNCOMMAND_USER + FULL_CURRENT_PATH)
Expand Down Expand Up @@ -468,12 +483,12 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
//scnNotification->nmhdr.code = NPPN_FILEBEFOREOPEN;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = BufferID;

#define NPPN_FILEBEFORESAVE (NPPN_FIRST + 7) // To notify plugins that the current file is about to be saved
//scnNotification->nmhdr.code = NPPN_FILEBEFOREOPEN;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = BufferID;

#define NPPN_FILESAVED (NPPN_FIRST + 8) // To notify plugins that the current file is just saved
//scnNotification->nmhdr.code = NPPN_FILESAVED;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
Expand Down Expand Up @@ -541,4 +556,44 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
//scnNotification->nmhdr.hwndFrom = NULL;
//scnNotification->nmhdr.idFrom = BufferID;

#define NPPN_BEFORESHUTDOWN (NPPN_FIRST + 19) // To notify plugins that Npp shutdown has been triggered, files have not been closed yet
//scnNotification->nmhdr.code = NPPN_BEFORESHUTDOWN;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = 0;

#define NPPN_CANCELSHUTDOWN (NPPN_FIRST + 20) // To notify plugins that Npp shutdown has been cancelled
//scnNotification->nmhdr.code = NPPN_CANCELSHUTDOWN;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = 0;

#define NPPN_FILEBEFORERENAME (NPPN_FIRST + 21) // To notify plugins that file is to be renamed
//scnNotification->nmhdr.code = NPPN_FILEBEFORERENAME;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = BufferID;

#define NPPN_FILERENAMECANCEL (NPPN_FIRST + 22) // To notify plugins that file rename has been cancelled
//scnNotification->nmhdr.code = NPPN_FILERENAMECANCEL;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = BufferID;

#define NPPN_FILERENAMED (NPPN_FIRST + 23) // To notify plugins that file has been renamed
//scnNotification->nmhdr.code = NPPN_FILERENAMED;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = BufferID;

#define NPPN_FILEBEFOREDELETE (NPPN_FIRST + 24) // To notify plugins that file is to be deleted
//scnNotification->nmhdr.code = NPPN_FILEBEFOREDELETE;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = BufferID;

#define NPPN_FILEDELETEFAILED (NPPN_FIRST + 25) // To notify plugins that file deletion has failed
//scnNotification->nmhdr.code = NPPN_FILEDELETEFAILED;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = BufferID;

#define NPPN_FILEDELETED (NPPN_FIRST + 26) // To notify plugins that file has been deleted
//scnNotification->nmhdr.code = NPPN_FILEDELETED;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = BufferID;

#endif //NOTEPAD_PLUS_MSGS_H
19 changes: 11 additions & 8 deletions src/npp/PluginInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
// version 2 of the License, or (at your option) any later version.
//
// Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a
// it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the
// following:
// following:
// 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield.
Expand Down Expand Up @@ -45,7 +45,8 @@ const int nbChar = 64;

typedef const TCHAR * (__cdecl * PFUNCGETNAME)();

struct NppData {
struct NppData
{
HWND _nppHandle;
HWND _scintillaMainHandle;
HWND _scintillaSecondHandle;
Expand All @@ -57,14 +58,16 @@ typedef void (__cdecl * PBENOTIFIED)(SCNotification *);
typedef LRESULT (__cdecl * PMESSAGEPROC)(UINT Message, WPARAM wParam, LPARAM lParam);


struct ShortcutKey {
struct ShortcutKey
{
bool _isCtrl;
bool _isAlt;
bool _isShift;
UCHAR _key;
};

struct FuncItem {
struct FuncItem
{
TCHAR _itemName[nbChar];
PFUNCPLUGINCMD _pFunc;
int _cmdID;
Expand All @@ -81,8 +84,8 @@ extern "C" __declspec(dllexport) FuncItem * getFuncsArray(int *);
extern "C" __declspec(dllexport) void beNotified(SCNotification *);
extern "C" __declspec(dllexport) LRESULT messageProc(UINT Message, WPARAM wParam, LPARAM lParam);

#ifdef UNICODE
// This API return always true now, since Notepad++ isn't compiled in ANSI mode anymore
extern "C" __declspec(dllexport) BOOL isUnicode();
#endif //UNICODE


#endif //PLUGININTERFACE_H
Loading

0 comments on commit aff025b

Please sign in to comment.