Add ability to style only current instance of text

Fix #9263, close #9684
This commit is contained in:
Scott Sumner 2021-03-22 16:52:54 -04:00 committed by Don HO
parent 09d6241686
commit 4369718925
8 changed files with 108 additions and 33 deletions

View File

@ -37,6 +37,7 @@ The comments are here for explanation, it's not necessary to translate them.
<Item subMenuId="edit-pasteSpecial" name="Paste Special"/>
<Item subMenuId="edit-onSelection" name="On Selection"/>
<Item subMenuId="search-markAll" name="Mark All"/>
<Item subMenuId="search-markOne" name="Mark One"/>
<Item subMenuId="search-unmarkAll" name="Unmark All"/>
<Item subMenuId="search-jumpUp" name="Jump Up"/>
<Item subMenuId="search-jumpDown" name="Jump Down"/>
@ -232,6 +233,11 @@ The comments are here for explanation, it's not necessary to translate them.
<Item id="43059" name="5th Style"/>
<Item id="43060" name="All Styles"/>
<Item id="43061" name="Find Style (Marked)"/>
<Item id="43062" name="Using 1st Style"/>
<Item id="43063" name="Using 2nd Style"/>
<Item id="43064" name="Using 3rd Style"/>
<Item id="43065" name="Using 4th Style"/>
<Item id="43066" name="Using 5th Style"/>
<Item id="43045" name="Search Results Window"/>
<Item id="43046" name="Next Search Result"/>
<Item id="43047" name="Previous Search Result"/>
@ -539,11 +545,16 @@ The comments are here for explanation, it's not necessary to translate them.
<Item id="45001" name="EOL Conversion to Windows (CR LF)"/>
<Item id="45002" name="EOL Conversion to Unix (LF)"/>
<Item id="45003" name="EOL Conversion to Macintosh (CR)"/>
<Item id="43022" name="Mark text using 1st style"/>
<Item id="43024" name="Mark text using 2nd style"/>
<Item id="43026" name="Mark text using 3rd style"/>
<Item id="43028" name="Mark text using 4th style"/>
<Item id="43030" name="Mark text using 5th style"/>
<Item id="43022" name="Mark all using 1st style"/>
<Item id="43024" name="Mark all using 2nd style"/>
<Item id="43026" name="Mark all using 3rd style"/>
<Item id="43028" name="Mark all using 4th style"/>
<Item id="43030" name="Mark all using 5th style"/>
<Item id="43062" name="Mark one using 1st style"/>
<Item id="43063" name="Mark one using 2nd style"/>
<Item id="43064" name="Mark one using 3rd style"/>
<Item id="43065" name="Mark one using 4th style"/>
<Item id="43066" name="Mark one using 5th style"/>
<Item id="43023" name="Clear marks using 1st style"/>
<Item id="43025" name="Clear marks using 2nd style"/>
<Item id="43027" name="Clear marks using 3rd style"/>

View File

@ -2205,11 +2205,11 @@ void Notepad_plus::setupColorSampleBitmapsOnMainMenuItems()
}
bitmapOnStyleMenuItemsInfo[] =
{
{ IDM_SEARCH_GONEXTMARKER5, SCE_UNIVERSAL_FOUND_STYLE_EXT5, { IDM_SEARCH_MARKALLEXT5, IDM_SEARCH_UNMARKALLEXT5, IDM_SEARCH_GOPREVMARKER5, IDM_SEARCH_STYLE5TOCLIP } },
{ IDM_SEARCH_GONEXTMARKER4, SCE_UNIVERSAL_FOUND_STYLE_EXT4, { IDM_SEARCH_MARKALLEXT4, IDM_SEARCH_UNMARKALLEXT4, IDM_SEARCH_GOPREVMARKER4, IDM_SEARCH_STYLE4TOCLIP } },
{ IDM_SEARCH_GONEXTMARKER3, SCE_UNIVERSAL_FOUND_STYLE_EXT3, { IDM_SEARCH_MARKALLEXT3, IDM_SEARCH_UNMARKALLEXT3, IDM_SEARCH_GOPREVMARKER3, IDM_SEARCH_STYLE3TOCLIP } },
{ IDM_SEARCH_GONEXTMARKER2, SCE_UNIVERSAL_FOUND_STYLE_EXT2, { IDM_SEARCH_MARKALLEXT2, IDM_SEARCH_UNMARKALLEXT2, IDM_SEARCH_GOPREVMARKER2, IDM_SEARCH_STYLE2TOCLIP } },
{ IDM_SEARCH_GONEXTMARKER1, SCE_UNIVERSAL_FOUND_STYLE_EXT1, { IDM_SEARCH_MARKALLEXT1, IDM_SEARCH_UNMARKALLEXT1, IDM_SEARCH_GOPREVMARKER1, IDM_SEARCH_STYLE1TOCLIP } },
{ IDM_SEARCH_GONEXTMARKER5, SCE_UNIVERSAL_FOUND_STYLE_EXT5, { IDM_SEARCH_MARKALLEXT5, IDM_SEARCH_MARKONEEXT5, IDM_SEARCH_UNMARKALLEXT5, IDM_SEARCH_GOPREVMARKER5, IDM_SEARCH_STYLE5TOCLIP } },
{ IDM_SEARCH_GONEXTMARKER4, SCE_UNIVERSAL_FOUND_STYLE_EXT4, { IDM_SEARCH_MARKALLEXT4, IDM_SEARCH_MARKONEEXT4, IDM_SEARCH_UNMARKALLEXT4, IDM_SEARCH_GOPREVMARKER4, IDM_SEARCH_STYLE4TOCLIP } },
{ IDM_SEARCH_GONEXTMARKER3, SCE_UNIVERSAL_FOUND_STYLE_EXT3, { IDM_SEARCH_MARKALLEXT3, IDM_SEARCH_MARKONEEXT3, IDM_SEARCH_UNMARKALLEXT3, IDM_SEARCH_GOPREVMARKER3, IDM_SEARCH_STYLE3TOCLIP } },
{ IDM_SEARCH_GONEXTMARKER2, SCE_UNIVERSAL_FOUND_STYLE_EXT2, { IDM_SEARCH_MARKALLEXT2, IDM_SEARCH_MARKONEEXT2, IDM_SEARCH_UNMARKALLEXT2, IDM_SEARCH_GOPREVMARKER2, IDM_SEARCH_STYLE2TOCLIP } },
{ IDM_SEARCH_GONEXTMARKER1, SCE_UNIVERSAL_FOUND_STYLE_EXT1, { IDM_SEARCH_MARKALLEXT1, IDM_SEARCH_MARKONEEXT1, IDM_SEARCH_UNMARKALLEXT1, IDM_SEARCH_GOPREVMARKER1, IDM_SEARCH_STYLE1TOCLIP } },
{ IDM_SEARCH_GONEXTMARKER_DEF, SCE_UNIVERSAL_FOUND_STYLE, { IDM_SEARCH_GOPREVMARKER_DEF, IDM_SEARCH_MARKEDTOCLIP } }
};

View File

@ -412,6 +412,14 @@ BEGIN
MENUITEM "Using 4th Style", IDM_SEARCH_MARKALLEXT4
MENUITEM "Using 5th Style", IDM_SEARCH_MARKALLEXT5
END
POPUP "Mark One"
BEGIN
MENUITEM "Using 1st Style", IDM_SEARCH_MARKONEEXT1
MENUITEM "Using 2nd Style", IDM_SEARCH_MARKONEEXT2
MENUITEM "Using 3rd Style", IDM_SEARCH_MARKONEEXT3
MENUITEM "Using 4th Style", IDM_SEARCH_MARKONEEXT4
MENUITEM "Using 5th Style", IDM_SEARCH_MARKONEEXT5
END
POPUP "Unmark All"
BEGIN
MENUITEM "Clear 1st Style", IDM_SEARCH_UNMARKALLEXT1

View File

@ -1263,10 +1263,10 @@ void Notepad_plus::command(int id)
_pEditView->getGenericSelectedText(text2Find, strSize, false);
_pEditView->getGenericWordOnCaretPos(text2Find2, strSize);
if (text2Find[0] == '\0')
{
_findReplaceDlg.markAll(text2Find2, styleID, true);
}
if (text2Find[0] == '\0')
{
_findReplaceDlg.markAll(text2Find2, styleID, true);
}
else
{
_findReplaceDlg.markAll(text2Find, styleID, lstrlen(text2Find) == lstrlen(text2Find2));
@ -1274,6 +1274,39 @@ void Notepad_plus::command(int id)
}
break;
case IDM_SEARCH_MARKONEEXT1:
case IDM_SEARCH_MARKONEEXT2:
case IDM_SEARCH_MARKONEEXT3:
case IDM_SEARCH_MARKONEEXT4:
case IDM_SEARCH_MARKONEEXT5:
{
int styleID;
if (id == IDM_SEARCH_MARKONEEXT1)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT1;
else if (id == IDM_SEARCH_MARKONEEXT2)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT2;
else if (id == IDM_SEARCH_MARKONEEXT3)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT3;
else if (id == IDM_SEARCH_MARKONEEXT4)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT4;
else // (id == IDM_SEARCH_MARKONEEXT5)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT5;
Sci_CharacterRange range = _pEditView->getSelection();
if (range.cpMin == range.cpMax)
{
auto caretPos = _pEditView->execute(SCI_GETCURRENTPOS, 0, 0);
range.cpMin = static_cast<int>(_pEditView->execute(SCI_WORDSTARTPOSITION, caretPos, true));
range.cpMax = static_cast<int>(_pEditView->execute(SCI_WORDENDPOSITION, caretPos, true));
}
if (range.cpMax > range.cpMin)
{
_pEditView->execute(SCI_SETINDICATORCURRENT, styleID);
_pEditView->execute(SCI_INDICATORFILLRANGE, range.cpMin, range.cpMax - range.cpMin);
}
}
break;
case IDM_SEARCH_UNMARKALLEXT1 :
case IDM_SEARCH_UNMARKALLEXT2 :
case IDM_SEARCH_UNMARKALLEXT3 :
@ -3683,14 +3716,19 @@ void Notepad_plus::command(int id)
case IDM_SEARCH_DELETEMARKEDLINES :
case IDM_SEARCH_DELETEUNMARKEDLINES :
case IDM_SEARCH_MARKALLEXT1 :
case IDM_SEARCH_UNMARKALLEXT1 :
case IDM_SEARCH_MARKALLEXT2 :
case IDM_SEARCH_UNMARKALLEXT2 :
case IDM_SEARCH_MARKALLEXT3 :
case IDM_SEARCH_UNMARKALLEXT3 :
case IDM_SEARCH_MARKALLEXT4 :
case IDM_SEARCH_UNMARKALLEXT4 :
case IDM_SEARCH_MARKALLEXT5 :
case IDM_SEARCH_MARKONEEXT1 :
case IDM_SEARCH_MARKONEEXT2 :
case IDM_SEARCH_MARKONEEXT3 :
case IDM_SEARCH_MARKONEEXT4 :
case IDM_SEARCH_MARKONEEXT5 :
case IDM_SEARCH_UNMARKALLEXT1 :
case IDM_SEARCH_UNMARKALLEXT2 :
case IDM_SEARCH_UNMARKALLEXT3 :
case IDM_SEARCH_UNMARKALLEXT4 :
case IDM_SEARCH_UNMARKALLEXT5 :
case IDM_SEARCH_CLEARALLMARKS :
case IDM_FORMAT_TODOS :

View File

@ -188,11 +188,16 @@ static const WinMenuKeyDefinition winKeyDefs[] =
{ VK_B, IDM_SEARCH_GOTOMATCHINGBRACE, true, false, false, nullptr },
{ VK_B, IDM_SEARCH_SELECTMATCHINGBRACES, true, true, false, nullptr },
{ VK_M, IDM_SEARCH_MARK, true, false, false, nullptr },
{ VK_NULL, IDM_SEARCH_MARKALLEXT1, false, false, false, TEXT("Mark search results using 1st style") },
{ VK_NULL, IDM_SEARCH_MARKALLEXT2, false, false, false, TEXT("Mark search results using 2nd style") },
{ VK_NULL, IDM_SEARCH_MARKALLEXT3, false, false, false, TEXT("Mark search results using 3rd style") },
{ VK_NULL, IDM_SEARCH_MARKALLEXT4, false, false, false, TEXT("Mark search results using 4th style") },
{ VK_NULL, IDM_SEARCH_MARKALLEXT5, false, false, false, TEXT("Mark search results using 5th style") },
{ VK_NULL, IDM_SEARCH_MARKALLEXT1, false, false, false, TEXT("Mark all using 1st style") },
{ VK_NULL, IDM_SEARCH_MARKALLEXT2, false, false, false, TEXT("Mark all using 2nd style") },
{ VK_NULL, IDM_SEARCH_MARKALLEXT3, false, false, false, TEXT("Mark all using 3rd style") },
{ VK_NULL, IDM_SEARCH_MARKALLEXT4, false, false, false, TEXT("Mark all using 4th style") },
{ VK_NULL, IDM_SEARCH_MARKALLEXT5, false, false, false, TEXT("Mark all using 5th style") },
{ VK_NULL, IDM_SEARCH_MARKONEEXT1, false, false, false, TEXT("Mark one using 1st style") },
{ VK_NULL, IDM_SEARCH_MARKONEEXT2, false, false, false, TEXT("Mark one using 2nd style") },
{ VK_NULL, IDM_SEARCH_MARKONEEXT3, false, false, false, TEXT("Mark one using 3rd style") },
{ VK_NULL, IDM_SEARCH_MARKONEEXT4, false, false, false, TEXT("Mark one using 4th style") },
{ VK_NULL, IDM_SEARCH_MARKONEEXT5, false, false, false, TEXT("Mark one using 5th style") },
{ VK_NULL, IDM_SEARCH_UNMARKALLEXT1, false, false, false, TEXT("Clear marks using 1st style") },
{ VK_NULL, IDM_SEARCH_UNMARKALLEXT2, false, false, false, TEXT("Clear marks using 2nd style") },
{ VK_NULL, IDM_SEARCH_UNMARKALLEXT3, false, false, false, TEXT("Clear marks using 3rd style") },

View File

@ -30,11 +30,17 @@ https://npp-user-manual.org/docs/config-files/#the-context-menu-contextmenu-xml
Use FolderName (optional) to create sub-menu. FolderName can be used in any type of item.
FolderName value can be in any language.
-->
<Item FolderName="Style token" id="43022"/>
<Item FolderName="Style token" id="43024"/>
<Item FolderName="Style token" id="43026"/>
<Item FolderName="Style token" id="43028"/>
<Item FolderName="Style token" id="43030"/>
<Item FolderName="Style all occurrences of token" id="43022"/>
<Item FolderName="Style all occurrences of token" id="43024"/>
<Item FolderName="Style all occurrences of token" id="43026"/>
<Item FolderName="Style all occurrences of token" id="43028"/>
<Item FolderName="Style all occurrences of token" id="43030"/>
<Item FolderName="Style one token" id="43062"/>
<Item FolderName="Style one token" id="43063"/>
<Item FolderName="Style one token" id="43064"/>
<Item FolderName="Style one token" id="43065"/>
<Item FolderName="Style one token" id="43066"/>
<Item FolderName="Remove style" id="43023"/>
<Item FolderName="Remove style" id="43025"/>

View File

@ -56,11 +56,12 @@ MenuPosition menuPos[] = {
{ 1, 19, -1, "edit-onSelection" },
{ 2, 18, -1, "search-markAll" },
{ 2, 19, -1, "search-unmarkAll" },
{ 2, 20, -1, "search-jumpUp" },
{ 2, 21, -1, "search-jumpDown" },
{ 2, 22, -1, "search-copyStyledText" },
{ 2, 24, -1, "search-bookmark" },
{ 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" },
{ 3, 4, -1, "view-currentFileIn" },
{ 3, 6, -1, "view-showSymbol" },

View File

@ -236,6 +236,12 @@
#define IDM_SEARCH_ALLSTYLESTOCLIP (IDM_SEARCH + 60)
#define IDM_SEARCH_MARKEDTOCLIP (IDM_SEARCH + 61)
#define IDM_SEARCH_MARKONEEXT1 (IDM_SEARCH + 62)
#define IDM_SEARCH_MARKONEEXT2 (IDM_SEARCH + 63)
#define IDM_SEARCH_MARKONEEXT3 (IDM_SEARCH + 64)
#define IDM_SEARCH_MARKONEEXT4 (IDM_SEARCH + 65)
#define IDM_SEARCH_MARKONEEXT5 (IDM_SEARCH + 66)
#define IDM_MISC (IDM + 3500)
#define IDM_FILESWITCHER_FILESCLOSE (IDM_MISC + 1)
#define IDM_FILESWITCHER_FILESCLOSEOTHERS (IDM_MISC + 2)