mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-26 23:34:44 +02:00
Add change history navgation commands
Add Go to next/prev change & clear change history commands. Fix #12248, close #13861
This commit is contained in:
parent
9011253a0a
commit
d9b98681f4
@ -5,7 +5,7 @@ Translation note:
|
||||
2. All the comments are for explanation, they are not for translation.
|
||||
-->
|
||||
<NotepadPlus>
|
||||
<Native-Langue name="English" filename="english.xml" version="8.5.3">
|
||||
<Native-Langue name="English" filename="english.xml" version="8.5.5">
|
||||
<Menu>
|
||||
<Main>
|
||||
<!-- Main Menu Entries -->
|
||||
@ -39,6 +39,7 @@ Translation note:
|
||||
<Item subMenuId="edit-blankOperations" name="&Blank Operations"/>
|
||||
<Item subMenuId="edit-pasteSpecial" name="&Paste Special"/>
|
||||
<Item subMenuId="edit-onSelection" name="&On Selection"/>
|
||||
<Item subMenuId="search-changeHistory" name="Change History"/>
|
||||
<Item subMenuId="search-markAll" name="Style &All Occurrences of Token"/>
|
||||
<Item subMenuId="search-markOne" name="Style &One Token"/>
|
||||
<Item subMenuId="search-unmarkAll" name="Clear Style"/>
|
||||
@ -251,6 +252,9 @@ Translation note:
|
||||
<Item id="43064" name="Using 3rd Style"/>
|
||||
<Item id="43065" name="Using 4th Style"/>
|
||||
<Item id="43066" name="Using 5th Style"/>
|
||||
<Item id="43067" name="Go to Next Change"/>
|
||||
<Item id="43068" name="Go to Previous Change"/>
|
||||
<Item id="43069" name="Clear Change History"/>
|
||||
<Item id="43045" name="Search Results &Window"/>
|
||||
<Item id="43046" name="Next Search Resul&t"/>
|
||||
<Item id="43047" name="Previous Search Resul&t"/>
|
||||
|
@ -5,7 +5,7 @@ Translation note:
|
||||
2. All the comments are for explanation, they are not for translation.
|
||||
-->
|
||||
<NotepadPlus>
|
||||
<Native-Langue name="English" filename="english_customizable.xml" version="8.5.3">
|
||||
<Native-Langue name="English" filename="english_customizable.xml" version="8.5.5">
|
||||
<Menu>
|
||||
<Main>
|
||||
<!-- Main Menu Entries -->
|
||||
@ -39,6 +39,7 @@ Translation note:
|
||||
<Item subMenuId="edit-blankOperations" name="&Blank Operations"/>
|
||||
<Item subMenuId="edit-pasteSpecial" name="&Paste Special"/>
|
||||
<Item subMenuId="edit-onSelection" name="&On Selection"/>
|
||||
<Item subMenuId="search-changeHistory" name="Change History"/>
|
||||
<Item subMenuId="search-markAll" name="Style &All Occurrences of Token"/>
|
||||
<Item subMenuId="search-markOne" name="Style &One Token"/>
|
||||
<Item subMenuId="search-unmarkAll" name="Clear Style"/>
|
||||
@ -251,6 +252,9 @@ Translation note:
|
||||
<Item id="43064" name="Using 3rd Style"/>
|
||||
<Item id="43065" name="Using 4th Style"/>
|
||||
<Item id="43066" name="Using 5th Style"/>
|
||||
<Item id="43067" name="Go to Next Change"/>
|
||||
<Item id="43068" name="Go to Previous Change"/>
|
||||
<Item id="43069" name="Clear Change History"/>
|
||||
<Item id="43045" name="Search Results &Window"/>
|
||||
<Item id="43046" name="Next Search Resul&t"/>
|
||||
<Item id="43047" name="Previous Search Resul&t"/>
|
||||
|
@ -3,7 +3,7 @@
|
||||
The comments are here for explanation, it's not necessary to translate them.
|
||||
-->
|
||||
<NotepadPlus>
|
||||
<Native-Langue name="français" filename="french.xml" version="8.5.1">
|
||||
<Native-Langue name="français" filename="french.xml" version="8.5.5">
|
||||
<Menu>
|
||||
<Main>
|
||||
<!-- Main Menu Entries -->
|
||||
@ -37,6 +37,7 @@ The comments are here for explanation, it's not necessary to translate them.
|
||||
<Item subMenuId="edit-blankOperations" name="Traitement des espacements"/>
|
||||
<Item subMenuId="edit-pasteSpecial" name="Collage spécial"/>
|
||||
<Item subMenuId="edit-onSelection" name="Pour la sélection"/>
|
||||
<Item subMenuId="search-changeHistory" name="Historique de Modification"/>
|
||||
<Item subMenuId="search-markAll" name="Marquer tout"/>
|
||||
<Item subMenuId="search-markOne" name="Marquer uniquement la sélection"/>
|
||||
<Item subMenuId="search-unmarkAll" name="Enlever toutes les marques"/>
|
||||
@ -248,6 +249,9 @@ The comments are here for explanation, it's not necessary to translate them.
|
||||
<Item id="43064" name="Appliquer le style 3"/>
|
||||
<Item id="43065" name="Appliquer le style 4"/>
|
||||
<Item id="43066" name="Appliquer le style 5"/>
|
||||
<Item id="43067" name="Aller à la prochaine modification"/>
|
||||
<Item id="43068" name="Aller à la modification précédente"/>
|
||||
<Item id="43069" name="Vider l'Historique de Modification"/>
|
||||
<Item id="43045" name="Fenêtre des résultats de recherche"/>
|
||||
<Item id="43046" name="Résultat de recherche suivant"/>
|
||||
<Item id="43047" name="Résultat de recherche précédent"/>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<NotepadPlus>
|
||||
<Native-Langue name="台灣繁體" filename="taiwaneseMandarin.xml" version="8.5.1">
|
||||
<Native-Langue name="台灣繁體" filename="taiwaneseMandarin.xml" version="8.5.5">
|
||||
<Menu>
|
||||
<Main>
|
||||
<!-- Main Menu Entries -->
|
||||
@ -34,6 +34,7 @@
|
||||
<Item subMenuId="edit-blankOperations" name="空格處理(&B)"/>
|
||||
<Item subMenuId="edit-pasteSpecial" name="特殊貼上(&P)"/>
|
||||
<Item subMenuId="edit-onSelection" name="選取字元(&O)"/>
|
||||
<Item subMenuId="search-changeHistory" name="文件修改紀錄"/>
|
||||
<Item subMenuId="search-markAll" name="全部標記(&A)"/>
|
||||
<Item subMenuId="search-markOne" name="僅標記選取(&O)"/>
|
||||
<Item subMenuId="search-unmarkAll" name="去除標記(&U)"/>
|
||||
@ -244,6 +245,9 @@
|
||||
<Item id="43064" name="使用樣式3"/>
|
||||
<Item id="43065" name="使用樣式4"/>
|
||||
<Item id="43066" name="使用樣式5"/>
|
||||
<Item id="43067" name="前往下一個更改"/>
|
||||
<Item id="43068" name="前往上一個更改"/>
|
||||
<Item id="43069" name="清除修改紀錄"/>
|
||||
<Item id="43045" name="搜尋結果視窗(&W)"/>
|
||||
<Item id="43046" name="下個搜尋結果(&T)"/>
|
||||
<Item id="43047" name="上個搜尋結果(&T)"/>
|
||||
|
@ -8667,4 +8667,84 @@ void Notepad_plus::clearChangesHistory()
|
||||
|
||||
SendMessage(_pEditView->getHSelf(), SCI_SETCHANGEHISTORY, chFlags, 0);
|
||||
SendMessage(_pEditView->getHSelf(), SCI_GOTOPOS, pos, 0);
|
||||
|
||||
checkUndoState();
|
||||
}
|
||||
|
||||
// Based on https://github.com/notepad-plus-plus/notepad-plus-plus/issues/12248#issuecomment-1258561261.
|
||||
void Notepad_plus::changedHistoryGoTo(int idGoTo)
|
||||
{
|
||||
int mask = (1 << SC_MARKNUM_HISTORY_REVERTED_TO_ORIGIN) |
|
||||
(1 << SC_MARKNUM_HISTORY_SAVED) |
|
||||
(1 << SC_MARKNUM_HISTORY_MODIFIED) |
|
||||
(1 << SC_MARKNUM_HISTORY_REVERTED_TO_MODIFIED);
|
||||
|
||||
intptr_t line = -1;
|
||||
intptr_t blockIndicator = _pEditView->getCurrentLineNumber();
|
||||
intptr_t lastLine = _pEditView->execute(SCI_GETLINECOUNT);
|
||||
|
||||
if (idGoTo == IDM_SEARCH_CHANGED_NEXT) // Next.
|
||||
{
|
||||
intptr_t currentLine = blockIndicator;
|
||||
|
||||
// Start from currentLine (not currentLine + 1) in case currentLine is not-changed and the next line IS changed. lastLine is at least *1*.
|
||||
for (intptr_t i = currentLine; i < lastLine; i++)
|
||||
{
|
||||
if (_pEditView->execute(SCI_MARKERGET, i) & mask)
|
||||
{
|
||||
if (i != blockIndicator) // Changed-line found in a different block.
|
||||
{
|
||||
line = i;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
blockIndicator++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (line == -1) // Wrap around.
|
||||
{
|
||||
intptr_t endRange = currentLine + 1; // "+ 1": currentLine might be *0*.
|
||||
for (intptr_t i = 0; i < endRange; i++)
|
||||
{
|
||||
if (_pEditView->execute(SCI_MARKERGET, i) & mask)
|
||||
{
|
||||
line = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else // Prev.
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
line = _pEditView->execute(SCI_MARKERPREVIOUS, blockIndicator, mask);
|
||||
// "line == -1": no changed-line found. "line != blockIndicator": changed-line found in a different block.
|
||||
if (line == -1 || line != blockIndicator)
|
||||
break;
|
||||
else
|
||||
blockIndicator--;
|
||||
}
|
||||
|
||||
if (line == -1) // Wrap around.
|
||||
{
|
||||
line = _pEditView->execute(SCI_MARKERPREVIOUS, lastLine - 1, mask);
|
||||
}
|
||||
}
|
||||
|
||||
if (line != -1)
|
||||
{
|
||||
_pEditView->execute(SCI_ENSUREVISIBLEENFORCEPOLICY, line);
|
||||
_pEditView->execute(SCI_GOTOLINE, line);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isSilent = NppParameters::getInstance().getNppGUI()._muteSounds;
|
||||
|
||||
if (!isSilent)
|
||||
::MessageBeep(MB_ICONEXCLAMATION);
|
||||
}
|
||||
}
|
@ -646,4 +646,5 @@ private:
|
||||
HBITMAP generateSolidColourMenuItemIcon(COLORREF colour);
|
||||
|
||||
void clearChangesHistory();
|
||||
void changedHistoryGoTo(int idGoTo);
|
||||
};
|
||||
|
@ -545,17 +545,17 @@ BEGIN
|
||||
MENUITEM "Open File", IDM_EDIT_OPENASFILE
|
||||
MENUITEM "Open Containing Folder in Explorer", IDM_EDIT_OPENINFOLDER
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Search on Internet", IDM_EDIT_SEARCHONINTERNET
|
||||
MENUITEM "Search on Internet", IDM_EDIT_SEARCHONINTERNET
|
||||
MENUITEM "Change Search Engine...", IDM_EDIT_CHANGESEARCHENGINE
|
||||
END
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Column Mode...", IDM_EDIT_COLUMNMODETIP
|
||||
MENUITEM "Column Mode...", IDM_EDIT_COLUMNMODETIP
|
||||
MENUITEM "Colum&n Editor...", IDM_EDIT_COLUMNMODE
|
||||
MENUITEM "Character &Panel", IDM_EDIT_CHAR_PANEL
|
||||
MENUITEM "Clipboard &History", IDM_EDIT_CLIPBOARDHISTORY_PANEL
|
||||
MENUITEM "Character &Panel", IDM_EDIT_CHAR_PANEL
|
||||
MENUITEM "Clipboard &History", IDM_EDIT_CLIPBOARDHISTORY_PANEL
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Set Read-Only", IDM_EDIT_SETREADONLY
|
||||
MENUITEM "Clear Read-Only Flag", IDM_EDIT_CLEARREADONLY
|
||||
MENUITEM "Clear Read-Only Flag", IDM_EDIT_CLEARREADONLY
|
||||
END
|
||||
|
||||
POPUP "&Search"
|
||||
@ -578,7 +578,13 @@ BEGIN
|
||||
MENUITEM "Select All Between &Matching Braces", IDM_SEARCH_SELECTMATCHINGBRACES
|
||||
MENUITEM "Mar&k...", IDM_SEARCH_MARK
|
||||
MENUITEM SEPARATOR
|
||||
|
||||
POPUP "Change History"
|
||||
BEGIN
|
||||
MENUITEM "Go to Next Change", IDM_SEARCH_CHANGED_NEXT
|
||||
MENUITEM "Go to Previous Change", IDM_SEARCH_CHANGED_PREV
|
||||
MENUITEM "Clear Change History", IDM_SEARCH_CLEAR_CHANGE_HISTORY
|
||||
END
|
||||
MENUITEM SEPARATOR
|
||||
POPUP "Style &All Occurrences of Token"
|
||||
BEGIN
|
||||
MENUITEM "Using 1st Style", IDM_SEARCH_MARKALLEXT1
|
||||
|
@ -1893,8 +1893,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
|
||||
if (notification->nmhdr.code == SCN_UPDATEUI)
|
||||
{
|
||||
checkClipboard(); //6
|
||||
checkUndoState(); //4
|
||||
checkClipboard();
|
||||
checkUndoState();
|
||||
}
|
||||
|
||||
if (wParam == LINKTRIGGERED)
|
||||
@ -2984,6 +2984,11 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
|
||||
_mainEditView.showChangeHistoryMargin(svp._isChangeHistoryEnabled);
|
||||
_subEditView.showChangeHistoryMargin(svp._isChangeHistoryEnabled);
|
||||
|
||||
enableCommand(IDM_SEARCH_CHANGED_PREV, svp._isChangeHistoryEnabled, MENU);
|
||||
enableCommand(IDM_SEARCH_CHANGED_NEXT, svp._isChangeHistoryEnabled, MENU);
|
||||
enableCommand(IDM_SEARCH_CLEAR_CHANGE_HISTORY, svp._isChangeHistoryEnabled, MENU);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -1680,6 +1680,15 @@ void Notepad_plus::command(int id)
|
||||
bookmarkClearAll();
|
||||
break;
|
||||
|
||||
case IDM_SEARCH_CHANGED_PREV:
|
||||
case IDM_SEARCH_CHANGED_NEXT:
|
||||
changedHistoryGoTo(id);
|
||||
break;
|
||||
|
||||
case IDM_SEARCH_CLEAR_CHANGE_HISTORY:
|
||||
clearChangesHistory();
|
||||
break;
|
||||
|
||||
case IDM_LANG_USER_DLG :
|
||||
{
|
||||
bool isUDDlgVisible = false;
|
||||
|
@ -589,7 +589,7 @@ bool Notepad_plus::doReload(BufferID id, bool alert)
|
||||
// many settings such as update status bar, clickable link etc.
|
||||
activateBuffer(id, currentView(), true);
|
||||
|
||||
if (NppParameters::getInstance().getSVP()._isChangeHistoryEnabled4NextSession)
|
||||
if (NppParameters::getInstance().getSVP()._isChangeHistoryEnabled)
|
||||
clearChangesHistory();
|
||||
|
||||
return res;
|
||||
|
@ -199,6 +199,9 @@ static const WinMenuKeyDefinition winKeyDefs[] =
|
||||
{ VK_G, IDM_SEARCH_GOTOLINE, true, false, false, nullptr },
|
||||
{ VK_B, IDM_SEARCH_GOTOMATCHINGBRACE, true, false, false, nullptr },
|
||||
{ VK_B, IDM_SEARCH_SELECTMATCHINGBRACES, true, true, false, nullptr },
|
||||
{ VK_NULL, IDM_SEARCH_CHANGED_PREV, false, false, false, nullptr },
|
||||
{ VK_NULL, IDM_SEARCH_CHANGED_NEXT, false, false, false, nullptr },
|
||||
{ VK_NULL, IDM_SEARCH_CLEAR_CHANGE_HISTORY, false, false, false, nullptr },
|
||||
{ VK_M, IDM_SEARCH_MARK, true, false, false, nullptr },
|
||||
{ VK_NULL, IDM_SEARCH_MARKALLEXT1, false, false, false, TEXT("Style all using 1st style") },
|
||||
{ VK_NULL, IDM_SEARCH_MARKALLEXT2, false, false, false, TEXT("Style all using 2nd style") },
|
||||
|
@ -58,13 +58,14 @@ MenuPosition menuPos[] = {
|
||||
{ 1, 20, -1, "edit-pasteSpecial" },
|
||||
{ 1, 21, -1, "edit-onSelection" },
|
||||
|
||||
{ 2, 18, -1, "search-markAll" },
|
||||
{ 2, 19, -1, "search-markOne" },
|
||||
{ 2, 20, -1, "search-unmarkAll" },
|
||||
{ 2, 21, -1, "search-jumpUp" },
|
||||
{ 2, 22, -1, "search-jumpDown" },
|
||||
{ 2, 23, -1, "search-copyStyledText" },
|
||||
{ 2, 25, -1, "search-bookmark" },
|
||||
{ 2, 18, -1, "search-changeHistory" },
|
||||
{ 2, 20, -1, "search-markAll" },
|
||||
{ 2, 21, -1, "search-markOne" },
|
||||
{ 2, 22, -1, "search-unmarkAll" },
|
||||
{ 2, 23, -1, "search-jumpUp" },
|
||||
{ 2, 24, -1, "search-jumpDown" },
|
||||
{ 2, 25, -1, "search-copyStyledText" },
|
||||
{ 2, 27, -1, "search-bookmark" },
|
||||
|
||||
{ 3, 5, -1, "view-currentFileIn" },
|
||||
{ 3, 7, -1, "view-showSymbol" },
|
||||
|
@ -251,6 +251,10 @@
|
||||
#define IDM_SEARCH_MARKONEEXT4 (IDM_SEARCH + 65)
|
||||
#define IDM_SEARCH_MARKONEEXT5 (IDM_SEARCH + 66)
|
||||
|
||||
#define IDM_SEARCH_CHANGED_NEXT (IDM_SEARCH + 67)
|
||||
#define IDM_SEARCH_CHANGED_PREV (IDM_SEARCH + 68)
|
||||
#define IDM_SEARCH_CLEAR_CHANGE_HISTORY (IDM_SEARCH + 69)
|
||||
|
||||
#define IDM_MISC (IDM + 3500)
|
||||
#define IDM_DOCLIST_FILESCLOSE (IDM_MISC + 1)
|
||||
#define IDM_DOCLIST_FILESCLOSEOTHERS (IDM_MISC + 2)
|
||||
|
Loading…
x
Reference in New Issue
Block a user