Skip to content

Commit

Permalink
- Updated NscLib to add script compatibility with NWN:EE patch 1.87.8…
Browse files Browse the repository at this point in the history
…193.35 (AKA: patch .35).

- Fixes a small bug in lexer XML generation.
- Fixes a typo on the configuration screen.
- Fixes a glitch when changing dark mode on notepad 8.5.*+.
  • Loading branch information
Leonard-The-Wise committed Jul 7, 2023
1 parent 79566a8 commit 6f883d3
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 61 deletions.
1 change: 1 addition & 0 deletions src/DarkMode/PluginDarkMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace PluginDarkMode
COLORREF linkText = 0;
COLORREF edge = 0;
COLORREF hotEdge = 0;
COLORREF disabledEdge = 0;
};

struct Options
Expand Down
5 changes: 3 additions & 2 deletions src/NWScriptCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ void NWScriptCompiler::processFile(bool fromMemory, char* fileContents)

// Create our compiler/disassembler
_compiler = std::make_unique<NscCompiler>(*_resourceManager, _settings->useNonBiowareExtenstions);
_compiler->NscSetLogger(&_logger);
_compiler->NscSetIncludePaths(_includePaths);
_compiler->NscSetCompilerErrorPrefix(SCRIPTERRORPREFIX);
_compiler->NscSetResourceCacheEnabled(true);
Expand Down Expand Up @@ -393,8 +394,8 @@ bool NWScriptCompiler::MakeDependenciesView(const std::set<std::string>& depende
// Get first path in dependencies for comparisons.
auto it = dependencies.begin();
int count = dependencyParser.setSubject(*it).match();
filesystem::path currentPath = matches[0][1];
filesystem::path comparePath;
fs::path currentPath = matches[0][1];
fs::path comparePath;

// For each different path, we write the topic information of that folder and then enumerate the files
int topicNumber = 1;
Expand Down
14 changes: 7 additions & 7 deletions src/NWScriptCompiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,26 @@ namespace NWScriptPlugin
}

// Sets destination to a VALID and existing directory (or else get an error)
void setDestinationDirectory(filesystem::path dest) {
void setDestinationDirectory(fs::path dest) {
if (!isValidDirectory(str2wstr(dest.string()).c_str()))
throw;
_destDir = dest;
}

// Sets source path to a VALID and existing file path (or else get an error)
void setSourceFilePath(filesystem::path source) {
void setSourceFilePath(fs::path source) {
if (!PathFileExists(source.c_str()))
throw;
_sourcePath = source;
}

// Returns the current set Destination Directory
filesystem::path getDestinationDirectory() {
fs::path getDestinationDirectory() {
return _destDir;
}

// Returns the current set Source File path
filesystem::path getSourceFilePath() {
fs::path getSourceFilePath() {
return _sourcePath;
}

Expand Down Expand Up @@ -138,16 +138,16 @@ namespace NWScriptPlugin

private:
std::unique_ptr<ResourceManager> _resourceManager;
unique_ptr<NscCompiler> _compiler;
std::unique_ptr<NscCompiler> _compiler;
bool _fetchPreprocessorOnly = false;
bool _makeDependencyView = false;
int _compilerMode = 0;
void (*_processingEndCallback)(HRESULT returnCode) = nullptr;

generic_string NWNHome;
std::vector<std::string> _includePaths;
filesystem::path _sourcePath;
filesystem::path _destDir;
fs::path _sourcePath;
fs::path _destDir;

Settings* _settings;

Expand Down
6 changes: 3 additions & 3 deletions src/NWScriptLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace NWScriptPlugin
generic_string fileName;
generic_string fileExt;
generic_string lineNumber;
filesystem::path filePath;
fs::path filePath;

bool operator==(const CompilerMessage& b) {
return messageType == b.messageType && messageText == b.messageText &&
Expand All @@ -51,7 +51,7 @@ namespace NWScriptPlugin
return compilerMessages[index];
}

filesystem::path getIncludeFile(size_t index) {
fs::path getIncludeFile(size_t index) {
return includeFiles[index];
}

Expand Down Expand Up @@ -114,7 +114,7 @@ namespace NWScriptPlugin

private:
std::vector<CompilerMessage> compilerMessages;
std::vector<filesystem::path> includeFiles;
std::vector<fs::path> includeFiles;
std::stringstream processorContents;

void (*_messageCallback)(const CompilerMessage& message);
Expand Down
109 changes: 99 additions & 10 deletions src/Plugin Interface/Notepad_plus_msgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ enum LangType {
L_ASN1, L_AVS, L_BLITZBASIC, L_PUREBASIC, L_FREEBASIC, \
L_CSOUND, L_ERLANG, L_ESCRIPT, L_FORTH, L_LATEX, \
L_MMIXAL, L_NIM, L_NNCRONTAB, L_OSCRIPT, L_REBOL, \
L_REGISTRY, L_RUST, L_SPICE, L_TXT2TAGS, L_VISUALPROLOG, L_TYPESCRIPT, \
L_REGISTRY, L_RUST, L_SPICE, L_TXT2TAGS, L_VISUALPROLOG, \
L_TYPESCRIPT, L_JSON5, L_MSSQL, L_GDSCRIPT, L_HOLLYWOOD, \
// 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 class ExternalLexerAutoIndentMode { Standard, C_Like, Custom };
enum class MacroStatus { Idle, RecordInProgress, RecordingStopped, PlayingBack };

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 };
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, WV_WIN11 };
enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 };


Expand Down Expand Up @@ -169,8 +170,8 @@ struct toolbarIcons {
#define NPPM_MAKECURRENTBUFFERDIRTY (NPPMSG + 44)
//BOOL NPPM_MAKECURRENTBUFFERDIRTY(0, 0)

#define NPPM_GETENABLETHEMETEXTUREFUNC (NPPMSG + 45)
//BOOL NPPM_GETENABLETHEMETEXTUREFUNC(0, 0)
#define NPPM_GETENABLETHEMETEXTUREFUNC_DEPRECATED (NPPMSG + 45)
//BOOL NPPM_GETENABLETHEMETEXTUREFUNC(0, 0) -- DEPRECATED : use EnableThemeDialogTexture from uxtheme.h instead

#define NPPM_GETPLUGINSCONFIGDIR (NPPMSG + 46)
//INT NPPM_GETPLUGINSCONFIGDIR(int strLen, TCHAR *str)
Expand Down Expand Up @@ -199,11 +200,31 @@ struct CommunicationInfo {
//void NPPM_TRIGGERTABBARCONTEXTMENU(int view, int index2Activate)

#define NPPM_GETNPPVERSION (NPPMSG + 50)
// int NPPM_GETNPPVERSION(0, 0)
// return version
// ex : v4.6
// HIWORD(version) == 4
// LOWORD(version) == 6
// int NPPM_GETNPPVERSION(BOOL ADD_ZERO_PADDING, 0)
// Get Notepad++ version
// HIWORD(returned_value) is major part of version: the 1st number
// LOWORD(returned_value) is minor part of version: the 3 last numbers
//
// ADD_ZERO_PADDING == TRUE
//
// version | HIWORD | LOWORD
//------------------------------
// 8.9.6.4 | 8 | 964
// 9 | 9 | 0
// 6.9 | 6 | 900
// 6.6.6 | 6 | 660
// 13.6.6.6 | 13 | 666
//
//
// ADD_ZERO_PADDING == FALSE
//
// version | HIWORD | LOWORD
//------------------------------
// 8.9.6.4 | 8 | 964
// 9 | 9 | 0
// 6.9 | 6 | 9
// 6.6.6 | 6 | 66
// 13.6.6.6 | 13 | 666

#define NPPM_HIDETABBAR (NPPMSG + 51)
// BOOL NPPM_HIDETABBAR(0, BOOL hideOrNot)
Expand Down Expand Up @@ -508,13 +529,72 @@ struct toolbarIconsWithDarkMode {
// COLORREF linkText = 0;
// COLORREF edge = 0;
// COLORREF hotEdge = 0;
// COLORREF disabledEdge = 0;
// };
// }
//
// Note: in the case of calling failure ("false" is returned), you may need to change NppDarkMode::Colors structure to:
// https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/PowerEditor/src/NppDarkMode.h#L32

#define NPPM_GETCURRENTCMDLINE (NPPMSG + 109)
// INT NPPM_GETCURRENTCMDLINE(size_t strLen, TCHAR *commandLineStr)
// Get the Current Command Line string.
// Returns the number of TCHAR copied/to copy.
// Users should call it with commandLineStr as NULL to get the required number of TCHAR (not including the terminating nul character),
// allocate commandLineStr buffer with the return value + 1, then call it again to get the current command line string.

#define NPPM_CREATELEXER (NPPMSG + 110)
// void* NPPM_CREATELEXER(0, const TCHAR *lexer_name)
// Returns the ILexer pointer created by Lexilla

#define NPPM_GETBOOKMARKID (NPPMSG + 111)
// void* NPPM_GETBOOKMARKID(0, 0)
// Returns the bookmark ID

#define NPPM_DARKMODESUBCLASSANDTHEME (NPPMSG + 112)
// ULONG NPPM_DARKMODESUBCLASSANDTHEME(ULONG dmFlags, HWND hwnd)
// Add support for generic dark mode.
//
// Docking panels don't need to call NPPM_DARKMODESUBCLASSANDTHEME for main hwnd.
// Subclassing is applied automatically unless DWS_USEOWNDARKMODE flag is used.
//
// Might not work properly in C# plugins.
//
// Returns succesful combinations of flags.
//

namespace NppDarkMode
{
// Standard flags for main parent after its children are initialized.
constexpr ULONG dmfInit = 0x0000000BUL;

// Standard flags for main parent usually used in NPPN_DARKMODECHANGED.
constexpr ULONG dmfHandleChange = 0x0000000CUL;
};

// Examples:
//
// - after controls initializations in WM_INITDIALOG, in WM_CREATE or after CreateWindow:
//
//auto success = static_cast<ULONG>(::SendMessage(nppData._nppHandle, NPPM_DARKMODESUBCLASSANDTHEME, static_cast<WPARAM>(NppDarkMode::dmfInit), reinterpret_cast<LPARAM>(mainHwnd)));
//
// - handling dark mode change:
//
//extern "C" __declspec(dllexport) void beNotified(SCNotification * notifyCode)
//{
// switch (notifyCode->nmhdr.code)
// {
// case NPPN_DARKMODECHANGED:
// {
// ::SendMessage(nppData._nppHandle, NPPM_DARKMODESUBCLASSANDTHEME, static_cast<WPARAM>(dmfHandleChange), reinterpret_cast<LPARAM>(mainHwnd));
// ::SetWindowPos(mainHwnd, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); // to redraw titlebar and window
// break;
// }
// }
//}


// For RUNCOMMAND_USER
#define VAR_NOT_RECOGNIZED 0
#define FULL_CURRENT_PATH 1
#define CURRENT_DIRECTORY 2
Expand All @@ -530,6 +610,7 @@ struct toolbarIconsWithDarkMode {
#define CURRENT_LINESTR 12

#define RUNCOMMAND_USER (WM_USER + 3000)

#define NPPM_GETFULLCURRENTPATH (RUNCOMMAND_USER + FULL_CURRENT_PATH)
#define NPPM_GETCURRENTDIRECTORY (RUNCOMMAND_USER + CURRENT_DIRECTORY)
#define NPPM_GETFILENAME (RUNCOMMAND_USER + FILE_NAME)
Expand All @@ -555,7 +636,6 @@ struct toolbarIconsWithDarkMode {
#define NPPM_GETNPPFULLFILEPATH (RUNCOMMAND_USER + NPP_FULL_FILE_PATH)



// Notification code
#define NPPN_FIRST 1000
#define NPPN_READY (NPPN_FIRST + 1) // To notify plugins that all the procedures of launchment of notepad++ are done.
Expand Down Expand Up @@ -705,3 +785,12 @@ struct toolbarIconsWithDarkMode {
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = 0;

#define NPPN_CMDLINEPLUGINMSG (NPPN_FIRST + 28) // To notify plugins that the new argument for plugins (via '-pluginMessage="YOUR_PLUGIN_ARGUMENT"' in command line) is available
//scnNotification->nmhdr.code = NPPN_CMDLINEPLUGINMSG;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = pluginMessage; //where pluginMessage is pointer of type wchar_t

#define NPPN_EXTERNALLEXERBUFFER (NPPN_FIRST + 29) // To notify lexer plugins that the buffer (in idFrom) is just applied to a external lexer
//scnNotification->nmhdr.code = NPPN_EXTERNALLEXERBUFFER;
//scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = BufferID; //where pluginMessage is pointer of type wchar_t
Loading

0 comments on commit 6f883d3

Please sign in to comment.