From dfe0f38cd336831c0cd65ae20e995967e038df90 Mon Sep 17 00:00:00 2001 From: T B Fowler Date: Sat, 2 May 2009 20:25:54 +0000 Subject: [PATCH] Merging change marker plugin branch back into trunk. git-svn-id: https://notepad-plus.svn.sourceforge.net/svnroot/nppifacelib/trunk@119 2fa2a738-4fc5-9a49-b7e4-8bd4648edc6b --- .../NppPlugin_ChangeMarker/src/NppPlugin.cpp | 5 ++-- .../src/NppPlugin_ChangeMarker.cpp | 27 ++++++++++++++++++- .../src/NppPlugin_ChangeMarker.h | 2 ++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/NppPlugins/NppPlugin_ChangeMarker/src/NppPlugin.cpp b/NppPlugins/NppPlugin_ChangeMarker/src/NppPlugin.cpp index 27c7ea2..f3d4de1 100644 --- a/NppPlugins/NppPlugin_ChangeMarker/src/NppPlugin.cpp +++ b/NppPlugins/NppPlugin_ChangeMarker/src/NppPlugin.cpp @@ -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); @@ -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); } diff --git a/NppPlugins/NppPlugin_ChangeMarker/src/NppPlugin_ChangeMarker.cpp b/NppPlugins/NppPlugin_ChangeMarker/src/NppPlugin_ChangeMarker.cpp index 31bd0f7..b097849 100644 --- a/NppPlugins/NppPlugin_ChangeMarker/src/NppPlugin_ChangeMarker.cpp +++ b/NppPlugins/NppPlugin_ChangeMarker/src/NppPlugin_ChangeMarker.cpp @@ -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 ChangedDocs_Set; ChangedDocs_Set _doc_set; @@ -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(); @@ -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 ); @@ -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 ); @@ -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; } @@ -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() { diff --git a/NppPlugins/NppPlugin_ChangeMarker/src/NppPlugin_ChangeMarker.h b/NppPlugins/NppPlugin_ChangeMarker/src/NppPlugin_ChangeMarker.h index 7fff2a8..1e2a498 100644 --- a/NppPlugins/NppPlugin_ChangeMarker/src/NppPlugin_ChangeMarker.h +++ b/NppPlugins/NppPlugin_ChangeMarker/src/NppPlugin_ChangeMarker.h @@ -35,6 +35,7 @@ enum MENU_COMMANDS { CMD_JUMPCHANGENEXT, CMD_JUMPLINEUP, CMD_JUMPLINEDOWN, + CMD_JUMPINCLUDESAVED, CMD_LINENUMBER, CMD_CHANGEMARK, CMD_HIGHLIGHT, @@ -159,6 +160,7 @@ void jumpChangePrev(); void jumpChangeNext(); void jumpLineUp(); void jumpLineDown(); +void jumpIncludeSaved(); void displayWithLineNumbers(); void displayWithChangeMarks(); void displayAsHighlight();