Skip to content

Commit

Permalink
Merge pull request #18 from superolmo/dev
Browse files Browse the repository at this point in the history
Moving to 0.1.2.0
  • Loading branch information
superolmo committed May 15, 2020
2 parents 27d4ac2 + 9d2416c commit 67f2703
Show file tree
Hide file tree
Showing 24 changed files with 1,602 additions and 418 deletions.
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
Notepad++ Plugin for reading large files

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

# How to install
# How to install using PluginAdmin
0. Select in the main window top menu Plugins->PluginAdmin...
1. Scroll to "BigFiles - Open Very Large Files"
2. Select and Install

# How to install manually
0. Download the BigFiles.dll file for your specific platform and Notepad++ version
1. Open Notepad++ as Administrator
2. Select in the main window top menu Settings->Import->Import Plugin(s)
Expand All @@ -14,19 +18,20 @@ At this point it should be installed in Notepad++ plugin subfolder.

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

# Structure
The plugin is developed based on the Plugin template from Don Ho at https://github.com/npp-plugins/plugintemplate
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.

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

# Future Work
# Future Work v0.2.0.0
- Add settings dialog and bigfiles.ini for changing page size
- Improve classification of file type [Text, Binary, ZIP, PDF, etc.] and activate Hex-Editor if it is installed
- Open sequence of files. Ex: data1.csv + data2.csv + etc.
Expand Down
Binary file modified Win32/Release/BigFiles.dll
Binary file not shown.
Binary file modified Win32/Release/BigFiles.zip
Binary file not shown.
16 changes: 12 additions & 4 deletions src/BigFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@

extern FuncItem funcItem[nbFunc];
extern NppData nppData;

extern void updateStatusBar3(FileTracker*);
extern void closeBufferID3(int buffer_ID);
extern int getBigFileRecordIndex3(int buffer_id);
extern std::vector<FileTracker> ftv;

BOOL APIENTRY DllMain(HANDLE hModule, DWORD reasonForCall, LPVOID /*lpReserved*/)
{
Expand All @@ -28,16 +31,20 @@ BOOL APIENTRY DllMain(HANDLE hModule, DWORD reasonForCall, LPVOID /*lpReserved*
{
case DLL_PROCESS_ATTACH:
pluginInit(hModule);

break;

case DLL_PROCESS_DETACH:
pluginCleanUp();

break;

case DLL_THREAD_ATTACH:

break;

case DLL_THREAD_DETACH:

break;
}

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

}
break;

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

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

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

VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,1,1,1
PRODUCTVERSION 0,1,1,1
FILEVERSION 0,1,2,0
PRODUCTVERSION 0,1,2,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -33,12 +34,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Claudio Olmi"
VALUE "FileDescription", "BigFiles Plugin for Notepad++ to read very large files"
VALUE "FileVersion", "0.1.1.1"
VALUE "FileVersion", "0.1.2.0"
VALUE "InternalName", "BigFiles.dll"
VALUE "LegalCopyright", "Copyright 2019 by Claudio Olmi"
VALUE "LegalCopyright", "Copyright 2020 by Claudio Olmi"
VALUE "OriginalFilename", "BigFiles.dll"
VALUE "ProductName", "BigFiles Plugin"
VALUE "ProductVersion", "0.1.1.1"
VALUE "ProductVersion", "0.1.2.0"
END
END
BLOCK "VarFileInfo"
Expand Down Expand Up @@ -84,6 +85,58 @@ IDB_BITMAP2 BITMAP "forward.bmp"

IDB_BITMAP3 BITMAP "open.bmp"

IDB_BITMAP4 BITMAP "down.bmp"

IDB_BITMAP5 BITMAP "up.bmp"


/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

IDD_FORMVIEW DIALOGEX 0, 0, 261, 154
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 400, 0, 0x0
BEGIN
GROUPBOX "Configuration",IDC_STATIC,14,7,227,69
EDITTEXT IDC_EDIT1,121,22,80,13,ES_RIGHT | ES_AUTOHSCROLL
LTEXT "Default Page Size",IDC_STATIC,25,22,88,15
CONTROL "Warn if Administrator",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,48,187,14
PUSHBUTTON "Save",IDC_BUTTON1,50,102,68,21
PUSHBUTTON "Cancel",IDC_BUTTON2,137,102,68,21
END


/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_FORMVIEW, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 254
TOPMARGIN, 7
BOTTOMMARGIN, 147
END
END
#endif // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// AFX_DIALOG_LAYOUT
//

IDD_FORMVIEW AFX_DIALOG_LAYOUT
BEGIN
0
END

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

Expand Down
96 changes: 96 additions & 0 deletions src/Configuration.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#include "Configuration.h"

Configuration::Configuration(NppData nppData) {
//Get directory where the configuration file is located
this->_getPluginDirectory(nppData);

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

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";
}

int Configuration::get_default_page_size_bytes() {
return this->default_page_size_bytes;
};
bool Configuration::get_default_isAdmin_warnings() {
return this->default_isAdmin_warnings;
};

/***********************************************************************************
Function was taken from Notepad++ plugin called Converter at
https://github.com/npp-plugins/converter/blob/master/source/PluginDefinition.cpp
Modified to suite BigFiles needs
*/
//
// if conf file does not exist, then create it and load it.

void Configuration::_getCmdsFromConf(const TCHAR* confPath)
{
TCHAR cmdNames[MAX_PATH];
::GetPrivateProfileSectionNames(cmdNames, MAX_PATH, confPath);
TCHAR* pFn = cmdNames;

if (*pFn && wcscmp(pFn, TEXT("BigFiles")) == 0)
{
int val = 0;
val = GetPrivateProfileInt(pFn, TEXT("page_size_bytes"), 0, confPath);
if (val != 0)
this->default_page_size_bytes = val;
val = GetPrivateProfileInt(pFn, TEXT("isAdmin_warnings"), 0, confPath);
this->default_isAdmin_warnings = val != 0;
}
else {
::MessageBox(NULL, TEXT("Configuration not found"), TEXT("BigFiles Plugin - Configuration::_getCmdsFromConf"), MB_OK);
}
}
void Configuration::loadConfFile(NppData nppData)
{

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

//Get the fully qualified name of the config file, function saves it in confFileNameFull
//_getPluginDirectory(nppData);

// If the file does not exist, save default values
if (!::PathFileExists(confFileNameFull.c_str()))
{
wsprintf(strMessage, TEXT("%s%s"), TEXT("First time usage. Writing new BigFile config file to "), confFileNameFull.c_str());
::MessageBox(NULL, strMessage, TEXT("BigFiles Plugin - loadConfFile"), MB_OK);
//Write default configuration file
std::ofstream confFile(confFileNameFull);
if (confFile)
confFile << confContent;
else
::MessageBox(NULL, TEXT("Something went wrong1"), TEXT("BigFiles Plugin - Configuration::loadConfFile"), MB_OK);
if (confFile.bad())
::MessageBox(NULL, TEXT("Something went wrong2"), TEXT("BigFiles Plugin - Configuration::loadConfFile"), MB_OK);
confFile.close();
}
//Get values from configuration file
_getCmdsFromConf(confFileNameFull.c_str());
}
void Configuration::editConf(NppData nppData)
{
//IDM_FILE_OPEN
if (!::PathFileExists(confFileNameFull.c_str()))
{
loadConfFile(nppData);
}
::SendMessage(nppData._nppHandle, NPPM_DOOPEN, 0, (LPARAM)confFileNameFull.c_str());
}
/*
End of copied section from
https://github.com/npp-plugins/converter/blob/master/source/PluginDefinition.cpp
*******************************************************************************************/
50 changes: 50 additions & 0 deletions src/Configuration.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#pragma once

#include "PluginInterface.h"
#include "resource.h"

/*
Used for:
Functions used:
std::ifstream
*/
#include <fstream>

/*
Used for:
PathFindExists
*/
#include <shlwapi.h>

class Configuration
{

// used for messages
wchar_t strMessage[1000];

// Default value of page size in bytes
int default_page_size_bytes = 100000;

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

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
void _getPluginDirectory(NppData nppData);

void _getCmdsFromConf(const TCHAR*);

public:
// Holds the fully qualified file name of the configuration file
std::wstring confFileNameFull;

// Constructor
Configuration(NppData);

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

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

0 comments on commit 67f2703

Please sign in to comment.