Skip to content

Commit

Permalink
Merging change marker plugin branch back into trunk.
Browse files Browse the repository at this point in the history
git-svn-id: https://notepad-plus.svn.sourceforge.net/svnroot/nppifacelib/trunk@119 2fa2a738-4fc5-9a49-b7e4-8bd4648edc6b
  • Loading branch information
T B Fowler authored and T B Fowler committed May 2, 2009
1 parent f3e6cb1 commit dfe0f38
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
5 changes: 3 additions & 2 deletions NppPlugins/NppPlugin_ChangeMarker/src/NppPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ BOOL APIENTRY DllMain(HANDLE hModule, DWORD reasonForCall, LPVOID /*lpReserved*/
setPluginFuncItem(TEXT("Jump: Next Change"), p_cm::jumpChangeNext,p_cm::CMD_JUMPCHANGENEXT);
setPluginFuncItem(TEXT("Jump: Changed Line Up"), p_cm::jumpLineUp,p_cm::CMD_JUMPLINEUP);
setPluginFuncItem(TEXT("Jump: Changed Line Down"), p_cm::jumpLineDown,p_cm::CMD_JUMPLINEDOWN);
setPluginFuncItem(TEXT("Include Saved Changes in Jump Line Up/Down"), p_cm::jumpIncludeSaved,p_cm::CMD_JUMPINCLUDESAVED);
setPluginFuncItem(TEXT(""), NULL); // A separator line.
setPluginFuncItem(TEXT("Display: Line Number Margin"), p_cm::displayWithLineNumbers, p_cm::CMD_LINENUMBER , true);
setPluginFuncItem(TEXT("Display: Change Mark Margin"), p_cm::displayWithChangeMarks, p_cm::CMD_CHANGEMARK, true);
Expand Down Expand Up @@ -183,12 +184,12 @@ void npp_plugin::About_func()
TEXT(" since it was last loaded, and since it was last saved.\r\n\r\n")
TEXT(" You can view lines with un-saved changes using the Jump menu commands.\n" )
TEXT(" Use Jump: Prev Change and Next Change to move through the changes in the order they were made.\n")
TEXT(" Use Jump: Changed Line Up and Down to move to the first un-saved change found in the direction chosen.\r\n\r\n")
TEXT(" Use Jump: Changed Line Up and Down to move to the first change found in the direction chosen.\r\n\r\n")
TEXT(" Disabling change tracking for a document will clear all markers and reset the change tracker. This\n")
TEXT(" can be used to clear old change marks, and keep your undo history, and not need to reload the document.\n")
TEXT(" Disabling the whole plugin will stop all change processing. If you have several large documents and\n")
TEXT(" will be doing bulk changes disabling the plugin will help speed up the process.\r\n\r\n")
TEXT(" Hopefully you find this to be a useful tool. Enjoy!\r\n")
TEXT(" Thell Fowler (almostautomated)"),
TEXT("Change Markers 1.1.0"), MB_OK);
TEXT("Change Markers 1.2.0"), MB_OK);
}
27 changes: 26 additions & 1 deletion NppPlugins/NppPlugin_ChangeMarker/src/NppPlugin_ChangeMarker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace mark = npp_plugin::markers;

// Namespace public static variables.
bool _doDisable = false;
bool _jumpIncludesSaved = false;
Change_Mark* cm[NB_CHANGEMARKERS];
typedef std::set<int> ChangedDocs_Set;
ChangedDocs_Set _doc_set;
Expand Down Expand Up @@ -666,6 +667,13 @@ void initPlugin()
cm[i]->setTargetMarginMenuItem( cm[i]->margin.getTarget() );
}

// Setup the jumping control option value, using reverse logic, then call the menu command
// which will toggle the value.
if ( xml::getGUIConfigValue( TEXT("JumpControl"), TEXT("includeSaved") ) == TEXT("false") ) {
_jumpIncludesSaved = true;
}
jumpIncludeSaved();

// Now that all the config values are set...
if (! ( xml::getGUIConfigValue( TEXT("SciMarkers"), TEXT("trackUNDOREDO") ) == TEXT("true") ) ) {
npp_plugin_changemarker::disablePlugin();
Expand Down Expand Up @@ -730,6 +738,11 @@ bool generateDefaultConfigXml()
element_guiConfig->SetAttribute( TEXT("margin"), TEXT("MARGIN_CHANGES") );
node_guiConfig->LinkEndChild( element_guiConfig );

TiXmlElement * element_guiConfig2 = new TiXmlElement( TEXT("GUIConfig") );
element_guiConfig2->SetAttribute( TEXT("name"), TEXT("JumpControl") );
element_guiConfig2->SetAttribute( TEXT("includeSaved"), TEXT("false") );
node_guiConfig->LinkEndChild( element_guiConfig2 );

tstring baseModuleName = npp_plugin::getModuleBaseName()->c_str();
TCHAR targetPath[MAX_PATH];
::SendMessage( hNpp(), NPPM_GETPLUGINSCONFIGDIR, MAX_PATH, (LPARAM)targetPath );
Expand Down Expand Up @@ -778,6 +791,7 @@ void jumpChangedLines( bool direction )
int nextLine;
int sci_marker_direction;
int sci_search_mask = ( 1 << cm[CM_NOTSAVED]->id );
if ( _jumpIncludesSaved ) sci_search_mask |= ( 1 << cm[CM_SAVED]->id );

if ( direction ) {
currLine = ( lineStart < lineMax ) ? ( lineStart + 1 ) : ( 0 );
Expand All @@ -796,7 +810,7 @@ void jumpChangedLines( bool direction )
}

if ( nextLine < 0 ) {
::MessageBox( hCurrView(), TEXT("No un-saved changes found!" ), TEXT("Jump to Changed Line"), MB_OK );
::MessageBox( hCurrView(), TEXT("No changes found to jump to!" ), TEXT("Jump to Changed Line"), MB_OK );
return;
}

Expand Down Expand Up @@ -998,6 +1012,17 @@ void jumpLineUp() { jumpChangedLines( false ); }
// Movement Control function.
void jumpLineDown() { jumpChangedLines( true ); }

// Move Control Option function.
void jumpIncludeSaved() {
_jumpIncludesSaved = !_jumpIncludesSaved;

int cmdID = getCmdId( CMD_JUMPINCLUDESAVED );
::SendMessage(npp_plugin::hNpp(), NPPM_SETMENUITEMCHECK, cmdID, _jumpIncludesSaved );

xml::setGUIConfigValue( TEXT("JumpControl"), TEXT("includeSaved"),
_jumpIncludesSaved?TEXT("true"):TEXT("false") );
}

// Global display margin control
void displayWithLineNumbers()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ enum MENU_COMMANDS {
CMD_JUMPCHANGENEXT,
CMD_JUMPLINEUP,
CMD_JUMPLINEDOWN,
CMD_JUMPINCLUDESAVED,
CMD_LINENUMBER,
CMD_CHANGEMARK,
CMD_HIGHLIGHT,
Expand Down Expand Up @@ -159,6 +160,7 @@ void jumpChangePrev();
void jumpChangeNext();
void jumpLineUp();
void jumpLineDown();
void jumpIncludeSaved();
void displayWithLineNumbers();
void displayWithChangeMarks();
void displayAsHighlight();
Expand Down

0 comments on commit dfe0f38

Please sign in to comment.