Skip to content

Commit 3196c9e

Browse files
authored
Merge pull request #23 from superolmo/dev
Dev
2 parents aa11d29 + 882777e commit 3196c9e

23 files changed

+326
-181
lines changed

.gitignore

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
1-
Skip to content
2-
Search or jump to…
3-
4-
Pull requests
5-
Issues
6-
Marketplace
7-
Explore
8-
9-
@superolmo
10-
2.9k
11-
90.3k45.7kgithub/gitignore
12-
Code Pull requests 107 Actions Projects 0 Security Insights
13-
gitignore/VisualStudio.gitignore
14-
@paulsmithkc paulsmithkc [VisualStudio] add Logs folder (#3143)
15-
26c3d84 21 days ago
16-
@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
17-
354 lines (284 sloc) 5.91 KB
18-
191
## Ignore Visual Studio temporary files, build results, and
202
## files generated by popular Visual Studio add-ons.
213
##

Win32/Release/BigFiles.dll

-227 KB
Binary file not shown.

Win32/Release/BigFiles.zip

628 Bytes
Binary file not shown.

src/BigFiles.cpp

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,33 @@ extern void updateStatusBar3(FileTracker*);
2323
extern void closeBufferID3(int buffer_ID);
2424
extern int getBigFileRecordIndex3(int buffer_id);
2525
extern std::vector<FileTracker> ftv;
26+
extern Configuration* bigfiles_config;
2627

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

30-
switch (reasonForCall)
31-
{
32-
case DLL_PROCESS_ATTACH:
33-
pluginInit(hModule);
34-
35-
break;
31+
switch (reasonForCall)
32+
{
33+
case DLL_PROCESS_ATTACH:
34+
pluginInit(hModule);
35+
36+
break;
3637

37-
case DLL_PROCESS_DETACH:
38-
pluginCleanUp();
39-
40-
break;
38+
case DLL_PROCESS_DETACH:
39+
pluginCleanUp();
4140

42-
case DLL_THREAD_ATTACH:
43-
44-
break;
41+
break;
4542

46-
case DLL_THREAD_DETACH:
47-
48-
break;
49-
}
43+
case DLL_THREAD_ATTACH:
5044

51-
return TRUE;
45+
break;
46+
47+
case DLL_THREAD_DETACH:
48+
49+
break;
50+
}
51+
52+
return TRUE;
5253
}
5354

5455

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

66-
extern "C" __declspec(dllexport) FuncItem * getFuncsArray(int *nbF)
67+
extern "C" __declspec(dllexport) FuncItem * getFuncsArray(int* nbF)
6768
{
6869
*nbF = nbFunc;
6970
return funcItem;
7071
}
7172

7273

73-
extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode)
74+
extern "C" __declspec(dllexport) void beNotified(SCNotification * notifyCode)
7475
{
75-
switch (notifyCode->nmhdr.code)
76+
int sci_bufferId = 0;
77+
int record_index = 0;
78+
sci_bufferId = notifyCode->nmhdr.idFrom;
79+
80+
switch (notifyCode->nmhdr.code)
7681
{
82+
case NPPN_FILEOPENED:
83+
{
84+
if (sci_bufferId == bigfiles_config->ConfFileBufferID) {
85+
bigfiles_config->ConfFileBufferID = 0;
86+
}
87+
}
88+
break;
89+
7790
case NPPN_SHUTDOWN:
7891
{
7992
commandMenuCleanUp();
@@ -85,21 +98,29 @@ extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode)
8598
commandRegToolbarIcons();
8699
}
87100
break;
88-
101+
89102
case NPPN_FILECLOSED:
90103
{
91104
//When the FileClosed event happens, the Scintilla Buffer gets closed.
92105
// BigFiles needs to remove the reference to the buffer ID.
93-
closeBufferID3((int)notifyCode->nmhdr.idFrom);
94-
106+
closeBufferID3(sci_bufferId);
95107
}
96108
break;
97109

110+
case NPPN_FILESAVED:
111+
{
112+
if (sci_bufferId == bigfiles_config->ConfFileBufferID) {
113+
msgBox_int(TEXT("Reloading Configuration"), sci_bufferId);
114+
bigfiles_config->loadConfFile();
115+
}
116+
}
117+
break;
118+
98119
case NPPN_BUFFERACTIVATED:
99120
{
100121
// This happens when a Scintilla Buffer tab has been activated
101122
// Update the current buffer reference in the BigFiles structure
102-
int record_index = getBigFileRecordIndex3((int)notifyCode->nmhdr.idFrom);
123+
record_index = getBigFileRecordIndex3(sci_bufferId);
103124
if (record_index >= 0)
104125
updateStatusBar3(&ftv[record_index]);
105126

src/BigFiles.rc

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
#pragma code_page(65001)
44

5-
#include <windows.h>
5+
#include "windows.h"
66
#include "resource.h"
77
/////////////////////////////////////////////////////////////////////////////
88
// English (United States) resources
@@ -16,8 +16,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
1616
//
1717

1818
VS_VERSION_INFO VERSIONINFO
19-
FILEVERSION 0,1,2,0
20-
PRODUCTVERSION 0,1,2,0
19+
FILEVERSION 0,1,3,0
20+
PRODUCTVERSION 0,1,3,0
2121
FILEFLAGSMASK 0x3fL
2222
#ifdef _DEBUG
2323
FILEFLAGS 0x1L
@@ -34,12 +34,12 @@ BEGIN
3434
BEGIN
3535
VALUE "CompanyName", "Claudio Olmi"
3636
VALUE "FileDescription", "BigFiles Plugin for Notepad++ to read very large files"
37-
VALUE "FileVersion", "0.1.2.0"
37+
VALUE "FileVersion", "0.1.3.0"
3838
VALUE "InternalName", "BigFiles.dll"
3939
VALUE "LegalCopyright", "Copyright 2020 by Claudio Olmi"
4040
VALUE "OriginalFilename", "BigFiles.dll"
4141
VALUE "ProductName", "BigFiles Plugin"
42-
VALUE "ProductVersion", "0.1.2.0"
42+
VALUE "ProductVersion", "0.1.3.0"
4343
END
4444
END
4545
BLOCK "VarFileInfo"
@@ -107,6 +107,18 @@ BEGIN
107107
PUSHBUTTON "Cancel",IDC_BUTTON2,137,102,68,21
108108
END
109109

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

111123
/////////////////////////////////////////////////////////////////////////////
112124
//
@@ -123,6 +135,14 @@ BEGIN
123135
TOPMARGIN, 7
124136
BOTTOMMARGIN, 147
125137
END
138+
139+
IDD_FORMVIEW1, DIALOG
140+
BEGIN
141+
LEFTMARGIN, 7
142+
RIGHTMARGIN, 178
143+
TOPMARGIN, 7
144+
BOTTOMMARGIN, 112
145+
END
126146
END
127147
#endif // APSTUDIO_INVOKED
128148

@@ -137,6 +157,11 @@ BEGIN
137157
0
138158
END
139159

160+
IDD_FORMVIEW1 AFX_DIALOG_LAYOUT
161+
BEGIN
162+
0
163+
END
164+
140165
#endif // English (United States) resources
141166
/////////////////////////////////////////////////////////////////////////////
142167

src/Configuration.cpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ Configuration::Configuration(NppData nppData) {
55
this->_getPluginDirectory(nppData);
66

77
//Load config file
8-
this->loadConfFile(nppData);
8+
this->loadConfFile();
99
}
1010

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

2020
int Configuration::get_default_page_size_bytes() {
@@ -23,6 +23,9 @@ int Configuration::get_default_page_size_bytes() {
2323
bool Configuration::get_default_isAdmin_warnings() {
2424
return this->default_isAdmin_warnings;
2525
};
26+
bool Configuration::get_default_BinaryFileType_warnings() {
27+
return this->default_BinaryFileType_warnings;
28+
};
2629

2730
/***********************************************************************************
2831
Function was taken from Notepad++ plugin called Converter at
@@ -41,23 +44,32 @@ void Configuration::_getCmdsFromConf(const TCHAR* confPath)
4144
if (*pFn && wcscmp(pFn, TEXT("BigFiles")) == 0)
4245
{
4346
int val = 0;
44-
val = GetPrivateProfileInt(pFn, TEXT("page_size_bytes"), 0, confPath);
47+
48+
// Get page_size_bytes
49+
val = GetPrivateProfileInt(pFn, TEXT("page_size_bytes"), 0, confPath); //TODO: If not found, it will return 0 right now, is this right?
4550
if (val != 0)
4651
this->default_page_size_bytes = val;
47-
val = GetPrivateProfileInt(pFn, TEXT("isAdmin_warnings"), 0, confPath);
52+
53+
// Get isAdmin_warnings
54+
val = GetPrivateProfileInt(pFn, TEXT("isAdmin_warnings"), 0, confPath); //TODO: If not found, it will return 0 right now, is this right?
4855
this->default_isAdmin_warnings = val != 0;
56+
57+
// Get BinaryFileType_warnings
58+
val = GetPrivateProfileInt(pFn, TEXT("BinaryFileType_warnings"), 0, confPath); //TODO: If not found, it will return 0 right now, is this right?
59+
this->default_BinaryFileType_warnings = val != 0;
4960
}
5061
else {
5162
::MessageBox(NULL, TEXT("Configuration not found"), TEXT("BigFiles Plugin - Configuration::_getCmdsFromConf"), MB_OK);
5263
}
5364
}
54-
void Configuration::loadConfFile(NppData nppData)
65+
void Configuration::loadConfFile()
5566
{
5667

5768
const char confContent[] = "\
5869
[BigFiles]\n\
5970
page_size_bytes=100000\n\
6071
isAdmin_warnings=1\n\
72+
BinaryFileType_warnings=1\n\
6173
\n";
6274

6375
//Get the fully qualified name of the config file, function saves it in confFileNameFull
@@ -81,12 +93,13 @@ isAdmin_warnings=1\n\
8193
//Get values from configuration file
8294
_getCmdsFromConf(confFileNameFull.c_str());
8395
}
96+
8497
void Configuration::editConf(NppData nppData)
8598
{
8699
//IDM_FILE_OPEN
87100
if (!::PathFileExists(confFileNameFull.c_str()))
88101
{
89-
loadConfFile(nppData);
102+
loadConfFile();
90103
}
91104
::SendMessage(nppData._nppHandle, NPPM_DOOPEN, 0, (LPARAM)confFileNameFull.c_str());
92105
}

src/Configuration.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class Configuration
2727

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

30+
int default_BinaryFileType_warnings = false;
31+
3032
private:
3133
// Function gets the directory path where the configuration folder is located
3234
// This function fills the global variable that is later used for loading and saving configurations
@@ -37,14 +39,18 @@ class Configuration
3739
public:
3840
// Holds the fully qualified file name of the configuration file
3941
std::wstring confFileNameFull;
42+
std::wstring confFilePath;
43+
44+
int ConfFileBufferID = 0;
4045

4146
// Constructor
4247
Configuration(NppData);
4348

44-
void loadConfFile(NppData nppData);
49+
void loadConfFile();
4550
void editConf(NppData nppData);
4651

4752
// Getters
4853
int get_default_page_size_bytes();
4954
bool get_default_isAdmin_warnings();
55+
bool get_default_BinaryFileType_warnings();
5056
} ;

0 commit comments

Comments
 (0)