Skip to content

Commit 67f2703

Browse files
authored
Merge pull request #18 from superolmo/dev
Moving to 0.1.2.0
2 parents 27d4ac2 + 9d2416c commit 67f2703

24 files changed

+1602
-418
lines changed

README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
Notepad++ Plugin for reading large files
33

44
# Compiling
5-
Solution has been developed in Visual Stusio 2019 with Windows XP compatibity.
6-
Output file x64/BigFiles.dll ready to be imported by Notepad++ 64bit, use Win32 for x86.
5+
Solution has been developed in Visual Studio 2019 with Windows XP compatibity x86 and x64
76

8-
# How to install
7+
# How to install using PluginAdmin
8+
0. Select in the main window top menu Plugins->PluginAdmin...
9+
1. Scroll to "BigFiles - Open Very Large Files"
10+
2. Select and Install
11+
12+
# How to install manually
913
0. Download the BigFiles.dll file for your specific platform and Notepad++ version
1014
1. Open Notepad++ as Administrator
1115
2. Select in the main window top menu Settings->Import->Import Plugin(s)
@@ -14,19 +18,20 @@ At this point it should be installed in Notepad++ plugin subfolder.
1418

1519
# How to use it
1620
1. Open Notepad++
17-
2. Select in the main window top menu Plugins->BigFiles->Open BigFile
21+
2. Select in the main window top menu Plugins->BigFiles->Open BigFile or from the toolbar
1822
3. Select file you want to open. Make sure it is a text file
1923
4. Use ALT+LEFT_ARROW and ALT+RIGHT_ARROW to change page backward and forward respectively
24+
5. Use ALT+UP_ARROW and ALT+DOWN_ARROW to jump to start or end of the file
2025

2126
# Structure
2227
The plugin is developed based on the Plugin template from Don Ho at https://github.com/npp-plugins/plugintemplate
2328
Big files are read using a small 100kB per page. No files are kept open. An internal structure keeps track of page number for every file opened by the plugin.
2429

25-
# Scope of Work
26-
1. Plugin must be able to preview very large files in Notepad++
27-
2. Plugin must have 3 buttons in the toolbar allowing the user to open a bigfile and moving pages backard and forward
30+
# Minimum Scope of Work
31+
1. Plugin must be able to preview very large files in Notepad++ independent of the language (Multi-Byte)
32+
2. Plugin must be able to move viewable page changing page backward or forward, and to jump to start or end
2833

29-
# Future Work
34+
# Future Work v0.2.0.0
3035
- Add settings dialog and bigfiles.ini for changing page size
3136
- Improve classification of file type [Text, Binary, ZIP, PDF, etc.] and activate Hex-Editor if it is installed
3237
- Open sequence of files. Ex: data1.csv + data2.csv + etc.

Win32/Release/BigFiles.dll

12.5 KB
Binary file not shown.

Win32/Release/BigFiles.zip

4.28 KB
Binary file not shown.

src/BigFiles.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919

2020
extern FuncItem funcItem[nbFunc];
2121
extern NppData nppData;
22-
22+
extern void updateStatusBar3(FileTracker*);
23+
extern void closeBufferID3(int buffer_ID);
24+
extern int getBigFileRecordIndex3(int buffer_id);
25+
extern std::vector<FileTracker> ftv;
2326

2427
BOOL APIENTRY DllMain(HANDLE hModule, DWORD reasonForCall, LPVOID /*lpReserved*/)
2528
{
@@ -28,16 +31,20 @@ BOOL APIENTRY DllMain(HANDLE hModule, DWORD reasonForCall, LPVOID /*lpReserved*
2831
{
2932
case DLL_PROCESS_ATTACH:
3033
pluginInit(hModule);
34+
3135
break;
3236

3337
case DLL_PROCESS_DETACH:
3438
pluginCleanUp();
39+
3540
break;
3641

3742
case DLL_THREAD_ATTACH:
43+
3844
break;
3945

4046
case DLL_THREAD_DETACH:
47+
4148
break;
4249
}
4350

@@ -83,17 +90,18 @@ extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode)
8390
{
8491
//When the FileClosed event happens, the Scintilla Buffer gets closed.
8592
// BigFiles needs to remove the reference to the buffer ID.
86-
closeBufferID((int)notifyCode->nmhdr.idFrom);
93+
closeBufferID3((int)notifyCode->nmhdr.idFrom);
8794

8895
}
8996
break;
9097

9198
case NPPN_BUFFERACTIVATED:
9299
{
93100
// This happens when a Scintilla Buffer tab has been activated
94-
int record_index = getBigFileRecordIndex((int)notifyCode->nmhdr.idFrom);
101+
// Update the current buffer reference in the BigFiles structure
102+
int record_index = getBigFileRecordIndex3((int)notifyCode->nmhdr.idFrom);
95103
if (record_index >= 0)
96-
updateStatusBar(record_index);
104+
updateStatusBar3(&ftv[record_index]);
97105

98106
}
99107
break;

src/BigFiles.rc

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

5+
#include <windows.h>
56
#include "resource.h"
67
/////////////////////////////////////////////////////////////////////////////
78
// English (United States) resources
@@ -15,8 +16,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
1516
//
1617

1718
VS_VERSION_INFO VERSIONINFO
18-
FILEVERSION 0,1,1,1
19-
PRODUCTVERSION 0,1,1,1
19+
FILEVERSION 0,1,2,0
20+
PRODUCTVERSION 0,1,2,0
2021
FILEFLAGSMASK 0x3fL
2122
#ifdef _DEBUG
2223
FILEFLAGS 0x1L
@@ -33,12 +34,12 @@ BEGIN
3334
BEGIN
3435
VALUE "CompanyName", "Claudio Olmi"
3536
VALUE "FileDescription", "BigFiles Plugin for Notepad++ to read very large files"
36-
VALUE "FileVersion", "0.1.1.1"
37+
VALUE "FileVersion", "0.1.2.0"
3738
VALUE "InternalName", "BigFiles.dll"
38-
VALUE "LegalCopyright", "Copyright 2019 by Claudio Olmi"
39+
VALUE "LegalCopyright", "Copyright 2020 by Claudio Olmi"
3940
VALUE "OriginalFilename", "BigFiles.dll"
4041
VALUE "ProductName", "BigFiles Plugin"
41-
VALUE "ProductVersion", "0.1.1.1"
42+
VALUE "ProductVersion", "0.1.2.0"
4243
END
4344
END
4445
BLOCK "VarFileInfo"
@@ -84,6 +85,58 @@ IDB_BITMAP2 BITMAP "forward.bmp"
8485

8586
IDB_BITMAP3 BITMAP "open.bmp"
8687

88+
IDB_BITMAP4 BITMAP "down.bmp"
89+
90+
IDB_BITMAP5 BITMAP "up.bmp"
91+
92+
93+
/////////////////////////////////////////////////////////////////////////////
94+
//
95+
// Dialog
96+
//
97+
98+
IDD_FORMVIEW DIALOGEX 0, 0, 261, 154
99+
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
100+
FONT 8, "MS Shell Dlg", 400, 0, 0x0
101+
BEGIN
102+
GROUPBOX "Configuration",IDC_STATIC,14,7,227,69
103+
EDITTEXT IDC_EDIT1,121,22,80,13,ES_RIGHT | ES_AUTOHSCROLL
104+
LTEXT "Default Page Size",IDC_STATIC,25,22,88,15
105+
CONTROL "Warn if Administrator",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,48,187,14
106+
PUSHBUTTON "Save",IDC_BUTTON1,50,102,68,21
107+
PUSHBUTTON "Cancel",IDC_BUTTON2,137,102,68,21
108+
END
109+
110+
111+
/////////////////////////////////////////////////////////////////////////////
112+
//
113+
// DESIGNINFO
114+
//
115+
116+
#ifdef APSTUDIO_INVOKED
117+
GUIDELINES DESIGNINFO
118+
BEGIN
119+
IDD_FORMVIEW, DIALOG
120+
BEGIN
121+
LEFTMARGIN, 7
122+
RIGHTMARGIN, 254
123+
TOPMARGIN, 7
124+
BOTTOMMARGIN, 147
125+
END
126+
END
127+
#endif // APSTUDIO_INVOKED
128+
129+
130+
/////////////////////////////////////////////////////////////////////////////
131+
//
132+
// AFX_DIALOG_LAYOUT
133+
//
134+
135+
IDD_FORMVIEW AFX_DIALOG_LAYOUT
136+
BEGIN
137+
0
138+
END
139+
87140
#endif // English (United States) resources
88141
/////////////////////////////////////////////////////////////////////////////
89142

src/Configuration.cpp

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#include "Configuration.h"
2+
3+
Configuration::Configuration(NppData nppData) {
4+
//Get directory where the configuration file is located
5+
this->_getPluginDirectory(nppData);
6+
7+
//Load config file
8+
this->loadConfFile(nppData);
9+
}
10+
11+
void Configuration::_getPluginDirectory(NppData nppData) {
12+
//TODO replace confFolder with confDir
13+
//TCHAR confFolder[1000];
14+
TCHAR confDir[MAX_PATH];
15+
::SendMessage(nppData._nppHandle, NPPM_GETPLUGINSCONFIGDIR, MAX_PATH, (LPARAM)confDir);
16+
//wcsncpy(confFolder, confDir, MAX_PATH);
17+
confFileNameFull = std::wstring(confDir) + L"\\bigfile.conf";
18+
}
19+
20+
int Configuration::get_default_page_size_bytes() {
21+
return this->default_page_size_bytes;
22+
};
23+
bool Configuration::get_default_isAdmin_warnings() {
24+
return this->default_isAdmin_warnings;
25+
};
26+
27+
/***********************************************************************************
28+
Function was taken from Notepad++ plugin called Converter at
29+
https://github.com/npp-plugins/converter/blob/master/source/PluginDefinition.cpp
30+
Modified to suite BigFiles needs
31+
*/
32+
//
33+
// if conf file does not exist, then create it and load it.
34+
35+
void Configuration::_getCmdsFromConf(const TCHAR* confPath)
36+
{
37+
TCHAR cmdNames[MAX_PATH];
38+
::GetPrivateProfileSectionNames(cmdNames, MAX_PATH, confPath);
39+
TCHAR* pFn = cmdNames;
40+
41+
if (*pFn && wcscmp(pFn, TEXT("BigFiles")) == 0)
42+
{
43+
int val = 0;
44+
val = GetPrivateProfileInt(pFn, TEXT("page_size_bytes"), 0, confPath);
45+
if (val != 0)
46+
this->default_page_size_bytes = val;
47+
val = GetPrivateProfileInt(pFn, TEXT("isAdmin_warnings"), 0, confPath);
48+
this->default_isAdmin_warnings = val != 0;
49+
}
50+
else {
51+
::MessageBox(NULL, TEXT("Configuration not found"), TEXT("BigFiles Plugin - Configuration::_getCmdsFromConf"), MB_OK);
52+
}
53+
}
54+
void Configuration::loadConfFile(NppData nppData)
55+
{
56+
57+
const char confContent[] = "\
58+
[BigFiles]\n\
59+
page_size_bytes=100000\n\
60+
isAdmin_warnings=1\n\
61+
\n";
62+
63+
//Get the fully qualified name of the config file, function saves it in confFileNameFull
64+
//_getPluginDirectory(nppData);
65+
66+
// If the file does not exist, save default values
67+
if (!::PathFileExists(confFileNameFull.c_str()))
68+
{
69+
wsprintf(strMessage, TEXT("%s%s"), TEXT("First time usage. Writing new BigFile config file to "), confFileNameFull.c_str());
70+
::MessageBox(NULL, strMessage, TEXT("BigFiles Plugin - loadConfFile"), MB_OK);
71+
//Write default configuration file
72+
std::ofstream confFile(confFileNameFull);
73+
if (confFile)
74+
confFile << confContent;
75+
else
76+
::MessageBox(NULL, TEXT("Something went wrong1"), TEXT("BigFiles Plugin - Configuration::loadConfFile"), MB_OK);
77+
if (confFile.bad())
78+
::MessageBox(NULL, TEXT("Something went wrong2"), TEXT("BigFiles Plugin - Configuration::loadConfFile"), MB_OK);
79+
confFile.close();
80+
}
81+
//Get values from configuration file
82+
_getCmdsFromConf(confFileNameFull.c_str());
83+
}
84+
void Configuration::editConf(NppData nppData)
85+
{
86+
//IDM_FILE_OPEN
87+
if (!::PathFileExists(confFileNameFull.c_str()))
88+
{
89+
loadConfFile(nppData);
90+
}
91+
::SendMessage(nppData._nppHandle, NPPM_DOOPEN, 0, (LPARAM)confFileNameFull.c_str());
92+
}
93+
/*
94+
End of copied section from
95+
https://github.com/npp-plugins/converter/blob/master/source/PluginDefinition.cpp
96+
*******************************************************************************************/

src/Configuration.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#pragma once
2+
3+
#include "PluginInterface.h"
4+
#include "resource.h"
5+
6+
/*
7+
Used for:
8+
Functions used:
9+
std::ifstream
10+
*/
11+
#include <fstream>
12+
13+
/*
14+
Used for:
15+
PathFindExists
16+
*/
17+
#include <shlwapi.h>
18+
19+
class Configuration
20+
{
21+
22+
// used for messages
23+
wchar_t strMessage[1000];
24+
25+
// Default value of page size in bytes
26+
int default_page_size_bytes = 100000;
27+
28+
int default_isAdmin_warnings = false; //If it is 1, it warns the user when Notepad++ is open in Admin mode.
29+
30+
private:
31+
// Function gets the directory path where the configuration folder is located
32+
// This function fills the global variable that is later used for loading and saving configurations
33+
void _getPluginDirectory(NppData nppData);
34+
35+
void _getCmdsFromConf(const TCHAR*);
36+
37+
public:
38+
// Holds the fully qualified file name of the configuration file
39+
std::wstring confFileNameFull;
40+
41+
// Constructor
42+
Configuration(NppData);
43+
44+
void loadConfFile(NppData nppData);
45+
void editConf(NppData nppData);
46+
47+
// Getters
48+
int get_default_page_size_bytes();
49+
bool get_default_isAdmin_warnings();
50+
} ;

0 commit comments

Comments
 (0)