Skip to content

Commit

Permalink
Cleanup of debugging statements and prep for release.
Browse files Browse the repository at this point in the history
git-svn-id: https://notepad-plus.svn.sourceforge.net/svnroot/nppifacelib/trunk@95 2fa2a738-4fc5-9a49-b7e4-8bd4648edc6b
  • Loading branch information
T B Fowler authored and T B Fowler committed Apr 5, 2009
1 parent 743f198 commit 82e9d96
Show file tree
Hide file tree
Showing 23 changed files with 107 additions and 346 deletions.
4 changes: 2 additions & 2 deletions NppPluginIface/src/NppPluginIface.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ typedef std::basic_string< TCHAR > tstring;
#endif

// <--- Initialization Functions --->
void initPlugin(tstring name, HANDLE hModule);
void initPlugin(tstring name, HANDLE hModule); // Set the module name, and save the module handle.
void setPluginFuncItem(tstring Name, PFUNCPLUGINCMD pFunction, int cmdID = NULL,
bool init2Check = false, ShortcutKey* pShKey = NULL); // Store a FuncItem command.
void setNppReady(); // Sets flag when Notepad++ is done with start up.
void hCurrViewNeedsUpdate(); // Sets flag to update hCurrView.

// <--- Data Retrieval Functions --->
HANDLE hModule(); // Plugin module's handle.
HANDLE hModule(); // Returns the plugin module's handle.
tstring* getModuleName(); // Returns the dll modules proper name.
tstring* getModuleBaseName(); // Returns the dll modules proper name without the .dll extension.
HWND hNpp(); // Returns the main Notepad++ handle.
Expand Down
2 changes: 1 addition & 1 deletion NppPluginIface/src/NppPluginIface_ActionHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ std::pair<ActionHistory_set::iterator, bool> DocumentActionHistory::insertAction
return ( retVal );
}

// Removes all actions item from the marker history after the current index.
// Removes all actions item from the action history after the current index.
void DocumentActionHistory::truncateActions()
{
int targetIndex = npp_plugin::actionindex::getCurrActionIndex( _currDoc );
Expand Down
26 changes: 6 additions & 20 deletions NppPluginIface/src/NppPluginIface_ActionIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@
*
* When tracking action counts for a Document the notifications received from the extra
* references must be discarded or the count is thrown out of synch with Scintilla's internal
* action counter. Unfortunately, Scintilla has both the current action count and ref count
* private with no get function for either, so it must be tracked from the container side.
* action counter.
*
* This source attempts to filter out the extra messages by comparing where the notification
* This source filters out the extra messages by comparing where the notification
* originated and determing if the notification should be handled by a particular view.
*
*/
Expand All @@ -57,7 +56,7 @@ namespace npp_plugin {
namespace actionindex {

// Un-named namespace for private classes, variables, and functions.
//namespace {
namespace {

// A few namespace scope globals for convience.
const bool PROCESS = false;
Expand Down Expand Up @@ -100,15 +99,15 @@ namespace actionindex {
return ( retVal );
}

//}; // End un-named namespace
}; // End un-named namespace


// Returns a target index for tracking actions, the index increments and decrements in relation
// with the messages reported via SCNotifications.
// Be sure to use the returned prevActionIndex value when dealing with UNDO messages. You are
// travelling backwards after all.
// 'SC_MOD_BEFORE...' the messages process as a 'Dry Run', the action count is returned
// but not stored, and the actual message will still be processed as normal.
// 'SC_MOD_BEFORE...' messages process as a 'Dry Run', the action count is returned
// but not stored, and the following SC_MOD_ message will still be processed as normal.
// The tuple returned is ( int pDoc, int prevActionIndex, int currActionCount, bool excluded, bool dryrun )
// If returned pDoc field is NULL the notification was not processed.
boost::tuples::tuple< int, int, int, bool, bool> processSCNotification( SCNotification* scn )
Expand Down Expand Up @@ -169,19 +168,6 @@ boost::tuples::tuple< int, int, int, bool, bool> processSCNotification( SCNotifi
}
}

/*
// REDO actions.
else if ( modFlags & ( SC_PERFORMED_REDO ) ) {
if ( modFlags & ( SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT ) ) {
newIndex++;
}
else if ( modFlags & ( SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE ) ) {
newIndex++;
dryrun = true;
}
}
*/

// Store the new action count if this isn't a dry-run.
if (! dryrun ) _ActionIndex[pDoc] = newIndex;

Expand Down
3 changes: 1 addition & 2 deletions NppPluginIface/src/NppPluginIface_CmdMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*
*/

//#include <unordered_map>
#include <boost/tr1/unordered_map.hpp> // Storage and mapping of original FuncItem cmdIDs.

#include "NppPluginIface_CmdMap.h"
Expand Down Expand Up @@ -57,7 +56,7 @@ int getCmdId ( int cmdId )
}

// Creates a mapping of the plugins internal funcItem CmdIDs to the funcItem array pointers
// send to N++ during the PluginsManager getFuncItemArray call during plugin loading.
// sent to N++ during the PluginsManager getFuncItemArray call during plugin loading.
// This makes it possible to use an enum of cmd id values within the plugin without having to
// ensure a particular order to the menu funcItems during funcItem initialization.
void createCmdIdMap ()
Expand Down
2 changes: 1 addition & 1 deletion NppPluginIface/src/NppPluginIface_CmdMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

namespace npp_plugin {

void createCmdIdMap (); // Creates a cmdID to funcItem mapping prior.
void createCmdIdMap (); // Creates a cmdID to funcItem mapping.
int getCmdId ( int cmdId ); // Returns the N++ assigned cmdId matching the plugin's assigned cmdId.


Expand Down
4 changes: 3 additions & 1 deletion NppPluginIface/src/NppPluginIface_DocTabMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

/*
* Notepad++ Plugin Interface Lib extension providing mapping of Notepad++ tab bufferID and
* visibility to Scintilla Document pointers.
* visibility to Scintilla Document pointers, as well as tracking the currently open files
* by docID and a docId to bufferID map.
*
* For an example of using this see NppPluginIface_ActionIndex.
*
Expand Down Expand Up @@ -62,6 +63,7 @@ struct DocTab {
using boost::multi_index::multi_index_container;
using namespace boost::multi_index;

// Namespace for the DocTab multi_index_container.
namespace doctabmap_mic {

// DocTab_set index key for comp_visible_key.
Expand Down
3 changes: 2 additions & 1 deletion NppPluginIface/src/NppPluginIface_DocTabMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

/*
* Notepad++ Plugin Interface Lib extension providing mapping of Notepad++ tab bufferID and
* visibility to Scintilla Document pointers.
* visibility to Scintilla Document pointers, as well as tracking the currently open files
* by docID and a docId to bufferID map.
*
* For an example of using this see NppPluginIface_ActionIndex.
*
Expand Down
7 changes: 3 additions & 4 deletions NppPluginIface/src/NppPluginIface_Markers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ void Margin::setMasks( int markerID )
// Unsets the mask for all margins in both views so the marker is on the previous target margin.
void Margin::restorePrevTarget( int markerID ) { setTarget( _prevTarget, markerID ); }

// Initializes Notepad++ and Scintilla to be able to use the markers from information set from
// the xml configuration data.
// Initializes Notepad++ and Scintilla to be able to use the markers.
void Plugin_Line_Marker::init( int markNum )
{
id = markNum;
Expand Down Expand Up @@ -286,13 +285,13 @@ bool Plugin_Line_Marker::getXpmDataFile()
// First try the application data folder.
TCHAR filePath[MAX_PATH];
::SendMessage( npp_plugin::hNpp(), NPPM_GETPLUGINSCONFIGDIR, MAX_PATH, (LPARAM)filePath );
PathAppend( filePath, TEXT("\\icons") );
PathAppend( filePath, TEXT("\\..\\icons") );
PathAppend( filePath, xpmFileName.c_str() );

if (!PathFileExists(filePath)) {
lstrcpyn( filePath, TEXT("\0"), MAX_PATH );
::SendMessage( npp_plugin::hNpp(), NPPM_GETNPPDIRECTORY, MAX_PATH, (LPARAM)filePath );
PathAppend( filePath, TEXT("plugins\\Config\\icons") );
PathAppend( filePath, TEXT("plugins\\icons") );
PathAppend( filePath, xpmFileName.c_str() );

if (!PathFileExists(filePath)) {
Expand Down
40 changes: 20 additions & 20 deletions NppPluginIface/src/NppPluginIface_Markers.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,26 @@ enum MARGIN {
NB_MARGINS
};

// Un-named namespace for private class/struct/variables. Mainly used to keep the
// interface clean.
//namespace {

// Margin control class.
class Margin
{
MARGIN _target;
MARGIN _prevTarget;
void setMasks( int markerID );

public:
void setTarget(MARGIN target, int markerID);
MARGIN getTarget() { return _target; };
void restorePrevTarget( int markerID );

Margin():_target(MARGIN_BOOKMARK), _prevTarget(MARGIN_BOOKMARK){};
};

// } // End: un-named namespace
// Un-named namespace for private class/struct/variables. Mainly used to keep the
// interface clean.
namespace {

// Margin control class.
class Margin
{
MARGIN _target;
MARGIN _prevTarget;
void setMasks( int markerID );

public:
void setTarget(MARGIN target, int markerID);
MARGIN getTarget() { return _target; };
void restorePrevTarget( int markerID );

Margin():_target(MARGIN_BOOKMARK), _prevTarget(MARGIN_BOOKMARK){};
};

} // End: un-named namespace

// This class provides the structure and functions that allow for a plugin to interact with
// Notepad++ and Scintilla to handle marker configuration and action tracking.
Expand Down
4 changes: 3 additions & 1 deletion NppPluginIface/src/NppPluginIface_XmlConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@ bool setGUIConfigValue( tstring name, tstring attrib, tstring value_ )
return ( retVal );
}

// Returns TiXmlDocument pointer to XmlConfigDoc, for convience reading values outside of GUIConfig node.
// Returns TiXmlDocument pointer to XmlConfigDoc, for convience reading values outside
// of the GUIConfig node. See the ChangeMarker plugin initPlugin routine to how how this is
// used for working with a wordstyle node.
TiXmlDocument* get_pXmlPluginConfigDoc()
{
if (! initXmlPluginConfig() ) return ( NULL );
Expand Down
110 changes: 1 addition & 109 deletions NppPlugins/NppPlugin_ChangeMarker/src/NppPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,63 +102,12 @@ extern "C" __declspec(dllexport) FuncItem * getFuncsArray(int *FuncsArraySize)
}


//---------------------------------------------------------------------------------------------
// Notepad++ and Scintilla Communications Processing

/*
* Listings of notifications and messages are in Notepad_plus_msgs.h and Scintilla.h.
*
* Notifications use the SCNotification structure described in Scintilla.h.
*
*/

// This function gives access to Notepad++'s notification facilities including forwarded
// notifications from Scintilla.
extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode)
{
/*
*
* Notifications can be filtered, and language specific handlers called using a
* Namespace::Function() call.
*
*/
using namespace npp_plugin;

//#define MSG_DEBUGGING
#ifdef MSG_DEBUGGING
npp_plugin::hCurrViewNeedsUpdate();
HWND hView = reinterpret_cast<HWND>(notifyCode->nmhdr.hwndFrom);
tstring ViewName;
if ( hView == hMainView() ) ViewName.assign( TEXT("MAIN_VIEW") );
else if ( hView == hSecondView() ) ViewName.assign( TEXT("SUB_VIEW") );
else if ( hView == hNpp() ) ViewName.assign( TEXT("Notepad++") );
else ViewName.assign( TEXT("NON_VIEW") ); // ie: Find/Replace

uptr_t idFrom = notifyCode->nmhdr.idFrom;
int idPos = ::SendMessage( hNpp(), NPPM_GETPOSFROMBUFFERID, idFrom, 0);
int idPos1 = idPos >> 30;
int idPos2 = idPos & 0xdf;
int bufferID = ::SendMessage( hView, NPPM_GETCURRENTBUFFERID, 0, 0);
static int mvFocusedBuffID = 0;
static int svFocusedBuffID = 0;
int buffPos = ::SendMessage( hNpp(), NPPM_GETPOSFROMBUFFERID, bufferID, 0);
int buffPos1 = buffPos >> 30;
int buffPos2 = buffPos & 0xdf;
int msg = notifyCode->nmhdr.code;
int pDoc = (LRESULT)::SendMessage( hView, SCI_GETDOCPOINTER, 0, 0);
int mvPDoc = (LRESULT)::SendMessage( hMainView(), SCI_GETDOCPOINTER, 0, 0);
static int mvFocusedPDoc = 0;
int svPDoc = (LRESULT)::SendMessage( hSecondView(), SCI_GETDOCPOINTER, 0, 0);
static int svFocusedPDoc = 0;
int flags = notifyCode->modificationType;
TCHAR flagHEX[65];
::_itot(flags, flagHEX, 16);
TCHAR flag2[65];
::_itot(flags, flag2, 2);
// Breakpoint string:
// {msg} {ViewName} idFrom:{idFrom}:[{idPos1}]:[{idPos2}] buffID:{bufferID}:[{buffPos1}]:[{buffPos2}] Doc:(curr){pDoc}|mv[{mvPDoc}]|sv[{svPDoc}] flags:({flags}):({flagHEX}):({flag2})
#endif

switch (notifyCode->nmhdr.code)
{
case SCN_MODIFIED:
Expand Down Expand Up @@ -192,14 +141,6 @@ extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode)
}
break;

case NPPN_FILEBEFOREOPEN:
npp_plugin::hCurrViewNeedsUpdate();
break;

case NPPN_FILEOPENED:
npp_plugin::hCurrViewNeedsUpdate();
break;

case NPPN_FILEBEFORECLOSE:
npp_plugin::hCurrViewNeedsUpdate();
p_cm::fileBeforeCloseHandler( notifyCode );
Expand All @@ -219,58 +160,9 @@ extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode)
extern "C" __declspec(dllexport) LRESULT messageProc(UINT Message, WPARAM wParam, LPARAM lParam)
{
/*
* This function give access to Notepad++'s messaging facilities. It was originally
* intended for the relay of Notepad++ messages and inter-plugin messages, yet having
* ::SendMessage( hCurrentView, SOME_MESSAGE_TOKENNAME, value, value );
* mixed in all over the place was ugly so this plugin uses messageProc to keep all of
* these in one area.
*
* This function either returns true or the return value that comes from each individual
* handler. So be sure to explicitly state the return in the switch case.
*
* Use the npp_plugin:: hCurrView, hMainView, hSecondView, and hNpp for the standard handles,
* some messages needs to be sent to both the main and second handle to get the desired
* results. ( Indicator setup messages are one example. )
*
* See Notepad_plus_msgs.h and Scintilla.h for notification IDs.
*
* Some messages sent to N++ get forwarded back here by N++ plugin notify. For instance
* NPPM_DOOPEN sent to messageProc will recieved a messageProc message again by the
* pluginNotify routine, so it needs to be sent via ::SendMessage
*
* This plugin does not make use of messageProc msgs.
*/

using namespace npp_plugin;
namespace msg = npp_plugin::messages;
namespace mark = npp_plugin::markers;

// ===> Include optional messaging handlers here.
switch (Message)
{

// <--- Notepad++ Messages --->
case NPPM_MSGTOPLUGIN:
{
// Inter-Plugin messaging
CommunicationInfo* comm = reinterpret_cast<CommunicationInfo *>(lParam);

switch ( comm->internalMsg )
{

default:
break;

break;
}

break;
}

default:
return false;

} // End: Switch ( Message )

return TRUE;
}

Expand Down
Loading

0 comments on commit 82e9d96

Please sign in to comment.