Skip to content

Commit

Permalink
Merge pull request #23 from superolmo/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
superolmo committed Jan 11, 2021
2 parents aa11d29 + 882777e commit 3196c9e
Show file tree
Hide file tree
Showing 23 changed files with 326 additions and 181 deletions.
18 changes: 0 additions & 18 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
Skip to content
Search or jump to…

Pull requests
Issues
Marketplace
Explore

@superolmo
2.9k
90.3k45.7kgithub/gitignore
Code Pull requests 107 Actions Projects 0 Security Insights
gitignore/VisualStudio.gitignore
@paulsmithkc paulsmithkc [VisualStudio] add Logs folder (#3143)
26c3d84 21 days ago
@shiftkey@arcresu@aroben@bbodenmiller@HassanHashemi@haacked@niik@AArnott@Zenuka@sayedihashimi@saschanaz@LunicLynx@OsirisTerje@sfhardman@jamiehumphries@richorama@RehanSaeed@marcrocny@matma@JFMG@jamesqo@elerch@cbadke@CoskunSunali@bdukes@anurse
354 lines (284 sloc) 5.91 KB

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
Expand Down
Binary file removed Win32/Release/BigFiles.dll
Binary file not shown.
Binary file modified Win32/Release/BigFiles.zip
Binary file not shown.
71 changes: 46 additions & 25 deletions src/BigFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,33 @@ extern void updateStatusBar3(FileTracker*);
extern void closeBufferID3(int buffer_ID);
extern int getBigFileRecordIndex3(int buffer_id);
extern std::vector<FileTracker> ftv;
extern Configuration* bigfiles_config;

BOOL APIENTRY DllMain(HANDLE hModule, DWORD reasonForCall, LPVOID /*lpReserved*/)
{

switch (reasonForCall)
{
case DLL_PROCESS_ATTACH:
pluginInit(hModule);
break;
switch (reasonForCall)
{
case DLL_PROCESS_ATTACH:
pluginInit(hModule);

break;

case DLL_PROCESS_DETACH:
pluginCleanUp();

break;
case DLL_PROCESS_DETACH:
pluginCleanUp();

case DLL_THREAD_ATTACH:

break;
break;

case DLL_THREAD_DETACH:

break;
}
case DLL_THREAD_ATTACH:

return TRUE;
break;

case DLL_THREAD_DETACH:

break;
}

return TRUE;
}


Expand All @@ -63,17 +64,29 @@ extern "C" __declspec(dllexport) const TCHAR * getName()
return NPP_PLUGIN_NAME;
}

extern "C" __declspec(dllexport) FuncItem * getFuncsArray(int *nbF)
extern "C" __declspec(dllexport) FuncItem * getFuncsArray(int* nbF)
{
*nbF = nbFunc;
return funcItem;
}


extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode)
extern "C" __declspec(dllexport) void beNotified(SCNotification * notifyCode)
{
switch (notifyCode->nmhdr.code)
int sci_bufferId = 0;
int record_index = 0;
sci_bufferId = notifyCode->nmhdr.idFrom;

switch (notifyCode->nmhdr.code)
{
case NPPN_FILEOPENED:
{
if (sci_bufferId == bigfiles_config->ConfFileBufferID) {
bigfiles_config->ConfFileBufferID = 0;
}
}
break;

case NPPN_SHUTDOWN:
{
commandMenuCleanUp();
Expand All @@ -85,21 +98,29 @@ extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode)
commandRegToolbarIcons();
}
break;

case NPPN_FILECLOSED:
{
//When the FileClosed event happens, the Scintilla Buffer gets closed.
// BigFiles needs to remove the reference to the buffer ID.
closeBufferID3((int)notifyCode->nmhdr.idFrom);

closeBufferID3(sci_bufferId);
}
break;

case NPPN_FILESAVED:
{
if (sci_bufferId == bigfiles_config->ConfFileBufferID) {
msgBox_int(TEXT("Reloading Configuration"), sci_bufferId);
bigfiles_config->loadConfFile();
}
}
break;

case NPPN_BUFFERACTIVATED:
{
// This happens when a Scintilla Buffer tab has been activated
// Update the current buffer reference in the BigFiles structure
int record_index = getBigFileRecordIndex3((int)notifyCode->nmhdr.idFrom);
record_index = getBigFileRecordIndex3(sci_bufferId);
if (record_index >= 0)
updateStatusBar3(&ftv[record_index]);

Expand Down
35 changes: 30 additions & 5 deletions src/BigFiles.rc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
#pragma code_page(65001)

#include <windows.h>
#include "windows.h"
#include "resource.h"
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
Expand All @@ -16,8 +16,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,1,2,0
PRODUCTVERSION 0,1,2,0
FILEVERSION 0,1,3,0
PRODUCTVERSION 0,1,3,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -34,12 +34,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Claudio Olmi"
VALUE "FileDescription", "BigFiles Plugin for Notepad++ to read very large files"
VALUE "FileVersion", "0.1.2.0"
VALUE "FileVersion", "0.1.3.0"
VALUE "InternalName", "BigFiles.dll"
VALUE "LegalCopyright", "Copyright 2020 by Claudio Olmi"
VALUE "OriginalFilename", "BigFiles.dll"
VALUE "ProductName", "BigFiles Plugin"
VALUE "ProductVersion", "0.1.2.0"
VALUE "ProductVersion", "0.1.3.0"
END
END
BLOCK "VarFileInfo"
Expand Down Expand Up @@ -107,6 +107,18 @@ BEGIN
PUSHBUTTON "Cancel",IDC_BUTTON2,137,102,68,21
END

IDD_FORMVIEW1 DIALOGEX 0, 0, 185, 119
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 400, 0, 0x0
BEGIN
LTEXT "Bytes per Page",IDC_STATIC,17,19,53,8
EDITTEXT IDC_EDIT1,71,17,81,14,ES_AUTOHSCROLL | ES_NUMBER,WS_EX_DLGMODALFRAME
CONTROL "Warn if running Notepad++ as Admin",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,39,141,15
CONTROL "Warn of non-text file format",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,56,138,17
PUSHBUTTON "Save",IDC_BUTTON1,19,86,61,19
PUSHBUTTON "Cancel",IDC_BUTTON2,101,86,61,19
END


/////////////////////////////////////////////////////////////////////////////
//
Expand All @@ -123,6 +135,14 @@ BEGIN
TOPMARGIN, 7
BOTTOMMARGIN, 147
END

IDD_FORMVIEW1, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 178
TOPMARGIN, 7
BOTTOMMARGIN, 112
END
END
#endif // APSTUDIO_INVOKED

Expand All @@ -137,6 +157,11 @@ BEGIN
0
END

IDD_FORMVIEW1 AFX_DIALOG_LAYOUT
BEGIN
0
END

#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////

Expand Down
27 changes: 20 additions & 7 deletions src/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ Configuration::Configuration(NppData nppData) {
this->_getPluginDirectory(nppData);

//Load config file
this->loadConfFile(nppData);
this->loadConfFile();
}

void Configuration::_getPluginDirectory(NppData nppData) {
//TODO replace confFolder with confDir
//TCHAR confFolder[1000];
TCHAR confDir[MAX_PATH];
::SendMessage(nppData._nppHandle, NPPM_GETPLUGINSCONFIGDIR, MAX_PATH, (LPARAM)confDir);
//wcsncpy(confFolder, confDir, MAX_PATH);
confFileNameFull = std::wstring(confDir) + L"\\bigfile.conf";
confFilePath = std::wstring(confDir);
confFileNameFull = confFilePath + L"\\bigfile.conf";
}

int Configuration::get_default_page_size_bytes() {
Expand All @@ -23,6 +23,9 @@ int Configuration::get_default_page_size_bytes() {
bool Configuration::get_default_isAdmin_warnings() {
return this->default_isAdmin_warnings;
};
bool Configuration::get_default_BinaryFileType_warnings() {
return this->default_BinaryFileType_warnings;
};

/***********************************************************************************
Function was taken from Notepad++ plugin called Converter at
Expand All @@ -41,23 +44,32 @@ void Configuration::_getCmdsFromConf(const TCHAR* confPath)
if (*pFn && wcscmp(pFn, TEXT("BigFiles")) == 0)
{
int val = 0;
val = GetPrivateProfileInt(pFn, TEXT("page_size_bytes"), 0, confPath);

// Get page_size_bytes
val = GetPrivateProfileInt(pFn, TEXT("page_size_bytes"), 0, confPath); //TODO: If not found, it will return 0 right now, is this right?
if (val != 0)
this->default_page_size_bytes = val;
val = GetPrivateProfileInt(pFn, TEXT("isAdmin_warnings"), 0, confPath);

// Get isAdmin_warnings
val = GetPrivateProfileInt(pFn, TEXT("isAdmin_warnings"), 0, confPath); //TODO: If not found, it will return 0 right now, is this right?
this->default_isAdmin_warnings = val != 0;

// Get BinaryFileType_warnings
val = GetPrivateProfileInt(pFn, TEXT("BinaryFileType_warnings"), 0, confPath); //TODO: If not found, it will return 0 right now, is this right?
this->default_BinaryFileType_warnings = val != 0;
}
else {
::MessageBox(NULL, TEXT("Configuration not found"), TEXT("BigFiles Plugin - Configuration::_getCmdsFromConf"), MB_OK);
}
}
void Configuration::loadConfFile(NppData nppData)
void Configuration::loadConfFile()
{

const char confContent[] = "\
[BigFiles]\n\
page_size_bytes=100000\n\
isAdmin_warnings=1\n\
BinaryFileType_warnings=1\n\
\n";

//Get the fully qualified name of the config file, function saves it in confFileNameFull
Expand All @@ -81,12 +93,13 @@ isAdmin_warnings=1\n\
//Get values from configuration file
_getCmdsFromConf(confFileNameFull.c_str());
}

void Configuration::editConf(NppData nppData)
{
//IDM_FILE_OPEN
if (!::PathFileExists(confFileNameFull.c_str()))
{
loadConfFile(nppData);
loadConfFile();
}
::SendMessage(nppData._nppHandle, NPPM_DOOPEN, 0, (LPARAM)confFileNameFull.c_str());
}
Expand Down
8 changes: 7 additions & 1 deletion src/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class Configuration

int default_isAdmin_warnings = false; //If it is 1, it warns the user when Notepad++ is open in Admin mode.

int default_BinaryFileType_warnings = false;

private:
// Function gets the directory path where the configuration folder is located
// This function fills the global variable that is later used for loading and saving configurations
Expand All @@ -37,14 +39,18 @@ class Configuration
public:
// Holds the fully qualified file name of the configuration file
std::wstring confFileNameFull;
std::wstring confFilePath;

int ConfFileBufferID = 0;

// Constructor
Configuration(NppData);

void loadConfFile(NppData nppData);
void loadConfFile();
void editConf(NppData nppData);

// Getters
int get_default_page_size_bytes();
bool get_default_isAdmin_warnings();
bool get_default_BinaryFileType_warnings();
} ;
Loading

0 comments on commit 3196c9e

Please sign in to comment.