Add copy styled text to clipboard commands to menu
Close #8943, close #8964
This commit is contained in:
parent
e32462188d
commit
013305f306
|
@ -37,6 +37,7 @@
|
|||
<Item subMenuId="search-unmarkAll" name="Unmark All"/>
|
||||
<Item subMenuId="search-jumpUp" name="Jump Up"/>
|
||||
<Item subMenuId="search-jumpDown" name="Jump Down"/>
|
||||
<Item subMenuId="search-copyStyledText" name="Copy Styled Text"/>
|
||||
<Item subMenuId="search-bookmark" name="Bookmark"/>
|
||||
<Item subMenuId="view-currentFileIn" name="View Current File in"/>
|
||||
<Item subMenuId="view-showSymbol" name="Show Symbol"/>
|
||||
|
@ -166,7 +167,6 @@
|
|||
<Item id="42029" name="Current File Path to Clipboard"/>
|
||||
<Item id="42030" name="Current Filename to Clipboard"/>
|
||||
<Item id="42031" name="Current Dir. Path to Clipboard"/>
|
||||
<Item id="42079" name="Marked Text to Clipboard"/>
|
||||
<Item id="42032" name="&Run a Macro Multiple Times..."/>
|
||||
<Item id="42033" name="Clear Read-Only Flag"/>
|
||||
<Item id="42035" name="Single Line Comment"/>
|
||||
|
@ -220,6 +220,13 @@
|
|||
<Item id="43042" name="4th style"/>
|
||||
<Item id="43043" name="5th style"/>
|
||||
<Item id="43044" name="Find style"/>
|
||||
<Item id="43055" name="1st Style"/>
|
||||
<Item id="43056" name="2nd Style"/>
|
||||
<Item id="43057" name="3rd Style"/>
|
||||
<Item id="43058" name="4th Style"/>
|
||||
<Item id="43059" name="5th Style"/>
|
||||
<Item id="43060" name="All Styles"/>
|
||||
<Item id="43061" name="Find Style (Marked)"/>
|
||||
<Item id="43045" name="Search Results Window"/>
|
||||
<Item id="43046" name="Next Search Result"/>
|
||||
<Item id="43047" name="Previous Search Result"/>
|
||||
|
@ -401,7 +408,7 @@
|
|||
<Item id="1703" name="&. matches newline"/>
|
||||
<Item id="1721" name="▲"/>
|
||||
<Item id="1723" name="▼ Find Next"/>
|
||||
<Item id="1725" name="Copy Marked Text to Clipboard"/>
|
||||
<Item id="1725" name="Copy Marked Text"/>
|
||||
</Find>
|
||||
|
||||
<FindCharsInRange title="Find Characters in Range...">
|
||||
|
@ -546,6 +553,13 @@
|
|||
<Item id="43042" name="Next mark using 4th style"/>
|
||||
<Item id="43043" name="Next mark using 5th style"/>
|
||||
<Item id="43044" name="Next mark created with Mark"/>
|
||||
<Item id="43055" name="Copy Styled Text - 1st Style"/>
|
||||
<Item id="43056" name="Copy Styled Text - 2nd Style"/>
|
||||
<Item id="43057" name="Copy Styled Text - 3rd Style"/>
|
||||
<Item id="43058" name="Copy Styled Text - 4th Style"/>
|
||||
<Item id="43059" name="Copy Styled Text - 5th Style"/>
|
||||
<Item id="43060" name="Copy Styled Text - All Styles"/>
|
||||
<Item id="43061" name="Copy Styled Text - Find Style (Marked)"/>
|
||||
<Item id="44100" name="View current file in Firefox"/>
|
||||
<Item id="44101" name="View current file in Chrome"/>
|
||||
<Item id="44103" name="View current file in IE"/>
|
||||
|
|
|
@ -288,8 +288,6 @@ BEGIN
|
|||
MENUITEM "Current Full File path to Clipboard", IDM_EDIT_FULLPATHTOCLIP
|
||||
MENUITEM "Current Filename to Clipboard", IDM_EDIT_FILENAMETOCLIP
|
||||
MENUITEM "Current Dir. Path to Clipboard", IDM_EDIT_CURRENTDIRTOCLIP
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Marked Text to Clipboard", IDM_EDIT_MARKEDTOCLIP
|
||||
END
|
||||
POPUP "Indent"
|
||||
BEGIN
|
||||
|
@ -450,6 +448,16 @@ BEGIN
|
|||
MENUITEM "5th Style", IDM_SEARCH_GONEXTMARKER5
|
||||
MENUITEM "Find Style", IDM_SEARCH_GONEXTMARKER_DEF
|
||||
END
|
||||
POPUP "Copy Styled Text"
|
||||
BEGIN
|
||||
MENUITEM "1st Style", IDM_SEARCH_STYLE1TOCLIP
|
||||
MENUITEM "2nd Style", IDM_SEARCH_STYLE2TOCLIP
|
||||
MENUITEM "3rd Style", IDM_SEARCH_STYLE3TOCLIP
|
||||
MENUITEM "4th Style", IDM_SEARCH_STYLE4TOCLIP
|
||||
MENUITEM "5th Style", IDM_SEARCH_STYLE5TOCLIP
|
||||
MENUITEM "All Styles", IDM_SEARCH_ALLSTYLESTOCLIP
|
||||
MENUITEM "Find Style (Marked)", IDM_SEARCH_MARKEDTOCLIP
|
||||
END
|
||||
MENUITEM SEPARATOR
|
||||
POPUP "Bookmark"
|
||||
BEGIN
|
||||
|
|
|
@ -1048,15 +1048,6 @@ void Notepad_plus::command(int id)
|
|||
}
|
||||
break;
|
||||
|
||||
case IDM_EDIT_MARKEDTOCLIP:
|
||||
{
|
||||
if (_findReplaceDlg.isCreated())
|
||||
{
|
||||
_findReplaceDlg.markedTextToClipboard(SCE_UNIVERSAL_FOUND_STYLE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_SEARCH_FIND :
|
||||
case IDM_SEARCH_REPLACE :
|
||||
case IDM_SEARCH_MARK :
|
||||
|
@ -1338,7 +1329,43 @@ void Notepad_plus::command(int id)
|
|||
}
|
||||
break;
|
||||
|
||||
case IDM_SEARCH_GOTOLINE :
|
||||
case IDM_SEARCH_STYLE1TOCLIP:
|
||||
{
|
||||
_pEditView->markedTextToClipboard(SCE_UNIVERSAL_FOUND_STYLE_EXT1);
|
||||
}
|
||||
break;
|
||||
case IDM_SEARCH_STYLE2TOCLIP:
|
||||
{
|
||||
_pEditView->markedTextToClipboard(SCE_UNIVERSAL_FOUND_STYLE_EXT2);
|
||||
}
|
||||
break;
|
||||
case IDM_SEARCH_STYLE3TOCLIP:
|
||||
{
|
||||
_pEditView->markedTextToClipboard(SCE_UNIVERSAL_FOUND_STYLE_EXT3);
|
||||
}
|
||||
break;
|
||||
case IDM_SEARCH_STYLE4TOCLIP:
|
||||
{
|
||||
_pEditView->markedTextToClipboard(SCE_UNIVERSAL_FOUND_STYLE_EXT4);
|
||||
}
|
||||
break;
|
||||
case IDM_SEARCH_STYLE5TOCLIP:
|
||||
{
|
||||
_pEditView->markedTextToClipboard(SCE_UNIVERSAL_FOUND_STYLE_EXT5);
|
||||
}
|
||||
break;
|
||||
case IDM_SEARCH_ALLSTYLESTOCLIP:
|
||||
{
|
||||
_pEditView->markedTextToClipboard(-1, true);
|
||||
}
|
||||
break;
|
||||
case IDM_SEARCH_MARKEDTOCLIP:
|
||||
{
|
||||
_pEditView->markedTextToClipboard(SCE_UNIVERSAL_FOUND_STYLE);
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_SEARCH_GOTOLINE:
|
||||
{
|
||||
bool isFirstTime = !_goToLineDlg.isCreated();
|
||||
_goToLineDlg.doDialog(_nativeLangSpeaker.isRTL());
|
||||
|
@ -3542,7 +3569,6 @@ void Notepad_plus::command(int id)
|
|||
case IDM_EDIT_FULLPATHTOCLIP :
|
||||
case IDM_EDIT_FILENAMETOCLIP :
|
||||
case IDM_EDIT_CURRENTDIRTOCLIP :
|
||||
case IDM_EDIT_MARKEDTOCLIP:
|
||||
case IDM_EDIT_CLEARREADONLY :
|
||||
case IDM_EDIT_RTL :
|
||||
case IDM_EDIT_LTR :
|
||||
|
@ -3613,6 +3639,13 @@ void Notepad_plus::command(int id)
|
|||
case IDM_SEARCH_GONEXTMARKER4 :
|
||||
case IDM_SEARCH_GONEXTMARKER5 :
|
||||
case IDM_SEARCH_GONEXTMARKER_DEF:
|
||||
case IDM_SEARCH_STYLE1TOCLIP:
|
||||
case IDM_SEARCH_STYLE2TOCLIP:
|
||||
case IDM_SEARCH_STYLE3TOCLIP:
|
||||
case IDM_SEARCH_STYLE4TOCLIP:
|
||||
case IDM_SEARCH_STYLE5TOCLIP:
|
||||
case IDM_SEARCH_ALLSTYLESTOCLIP:
|
||||
case IDM_SEARCH_MARKEDTOCLIP:
|
||||
case IDM_SEARCH_VOLATILE_FINDNEXT:
|
||||
case IDM_SEARCH_VOLATILE_FINDPREV:
|
||||
case IDM_SEARCH_CUTMARKEDLINES :
|
||||
|
|
|
@ -117,7 +117,6 @@ static const WinMenuKeyDefinition winKeyDefs[] =
|
|||
{ VK_NULL, IDM_EDIT_FULLPATHTOCLIP, false, false, false, nullptr },
|
||||
{ VK_NULL, IDM_EDIT_FILENAMETOCLIP, false, false, false, nullptr },
|
||||
{ VK_NULL, IDM_EDIT_CURRENTDIRTOCLIP, false, false, false, nullptr },
|
||||
{ VK_NULL, IDM_EDIT_MARKEDTOCLIP, false, false, false, nullptr },
|
||||
{ VK_NULL, IDM_EDIT_INS_TAB, false, false, false, nullptr },
|
||||
{ VK_NULL, IDM_EDIT_RMV_TAB, false, false, false, nullptr },
|
||||
{ VK_U, IDM_EDIT_UPPERCASE, true, false, true, nullptr },
|
||||
|
@ -223,7 +222,13 @@ static const WinMenuKeyDefinition winKeyDefs[] =
|
|||
{ VK_4, IDM_SEARCH_GONEXTMARKER4, true, false, false, TEXT("Next mark using 4th style") },
|
||||
{ VK_5, IDM_SEARCH_GONEXTMARKER5, true, false, false, TEXT("Next mark using 5th style") },
|
||||
{ VK_0, IDM_SEARCH_GONEXTMARKER_DEF, true, false, false, TEXT("Next mark created with Mark") },
|
||||
|
||||
{ VK_NULL, IDM_SEARCH_STYLE1TOCLIP, false, false, false, TEXT("Copy Styled Text - 1st Style") },
|
||||
{ VK_NULL, IDM_SEARCH_STYLE2TOCLIP, false, false, false, TEXT("Copy Styled Text - 2nd Style") },
|
||||
{ VK_NULL, IDM_SEARCH_STYLE3TOCLIP, false, false, false, TEXT("Copy Styled Text - 3rd Style") },
|
||||
{ VK_NULL, IDM_SEARCH_STYLE4TOCLIP, false, false, false, TEXT("Copy Styled Text - 4th Style") },
|
||||
{ VK_NULL, IDM_SEARCH_STYLE5TOCLIP, false, false, false, TEXT("Copy Styled Text - 5th Style") },
|
||||
{ VK_NULL, IDM_SEARCH_ALLSTYLESTOCLIP, false, false, false, TEXT("Copy Styled Text - All Styles") },
|
||||
{ VK_NULL, IDM_SEARCH_MARKEDTOCLIP, false, false, false, TEXT("Copy Styled Text - Find Style (Marked)") },
|
||||
{ VK_F2, IDM_SEARCH_TOGGLE_BOOKMARK, true, false, false, nullptr },
|
||||
{ VK_F2, IDM_SEARCH_NEXT_BOOKMARK, false, false, false, nullptr },
|
||||
{ VK_F2, IDM_SEARCH_PREV_BOOKMARK, false, false, true, nullptr },
|
||||
|
|
|
@ -1460,7 +1460,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||
|
||||
case IDC_COPY_MARKED_TEXT:
|
||||
{
|
||||
markedTextToClipboard(SCE_UNIVERSAL_FOUND_STYLE);
|
||||
(*_ppEditView)->markedTextToClipboard(SCE_UNIVERSAL_FOUND_STYLE);
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
|
@ -3406,48 +3406,6 @@ bool FindReplaceDlg::replaceInOpenDocsConfirmCheck(void)
|
|||
return confirmed;
|
||||
}
|
||||
|
||||
void FindReplaceDlg::markedTextToClipboard(int indiStyle)
|
||||
{
|
||||
auto pos = (*_ppEditView)->execute(SCI_INDICATOREND, indiStyle, 0);
|
||||
if (pos > 0)
|
||||
{
|
||||
std::vector<generic_string> markedTextStr;
|
||||
bool atEndOfIndic = (*_ppEditView)->execute(SCI_INDICATORVALUEAT, indiStyle, 0) != 0;
|
||||
auto prevPos = pos;
|
||||
if (atEndOfIndic) prevPos = 0;
|
||||
|
||||
const generic_string cr = TEXT("\r");
|
||||
const generic_string lf = TEXT("\n");
|
||||
bool dataHasLineEndingChar = false;
|
||||
|
||||
do
|
||||
{
|
||||
if (atEndOfIndic)
|
||||
{
|
||||
generic_string s = (*_ppEditView)->getGenericTextAsString(prevPos, pos);
|
||||
if (!dataHasLineEndingChar)
|
||||
{
|
||||
if (s.find(cr) != std::string::npos || s.find(lf) != std::string::npos)
|
||||
{
|
||||
dataHasLineEndingChar = true;
|
||||
}
|
||||
}
|
||||
markedTextStr.push_back(s);
|
||||
}
|
||||
atEndOfIndic = !atEndOfIndic;
|
||||
prevPos = pos;
|
||||
pos = (*_ppEditView)->execute(SCI_INDICATOREND, indiStyle, pos);
|
||||
} while (pos != prevPos);
|
||||
|
||||
if (markedTextStr.size() > 0)
|
||||
{
|
||||
const generic_string delim = dataHasLineEndingChar ? TEXT("\r\n----\r\n") : TEXT("\r\n");
|
||||
generic_string joined = stringJoin(markedTextStr, delim) + delim;
|
||||
str2Clipboard(joined, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
generic_string Finder::getHitsString(int count) const
|
||||
{
|
||||
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
|
||||
|
|
|
@ -340,7 +340,6 @@ public :
|
|||
generic_string getScopeInfoForStatusBar(FindOption const *pFindOpt) const;
|
||||
Finder * createFinder();
|
||||
bool removeFinder(Finder *finder2remove);
|
||||
void markedTextToClipboard(int indiStyle);
|
||||
|
||||
protected :
|
||||
void resizeDialogElements(LONG newWidth);
|
||||
|
|
|
@ -3786,3 +3786,88 @@ int ScintillaEditView::getUnicodeSelectedLength() const
|
|||
|
||||
return length;
|
||||
};
|
||||
|
||||
|
||||
void ScintillaEditView::markedTextToClipboard(int indiStyle, bool doAll /*= false*/)
|
||||
{
|
||||
int styleIndicators[] =
|
||||
{
|
||||
SCE_UNIVERSAL_FOUND_STYLE_EXT1,
|
||||
SCE_UNIVERSAL_FOUND_STYLE_EXT2,
|
||||
SCE_UNIVERSAL_FOUND_STYLE_EXT3,
|
||||
SCE_UNIVERSAL_FOUND_STYLE_EXT4,
|
||||
SCE_UNIVERSAL_FOUND_STYLE_EXT5,
|
||||
-1 // end signifier
|
||||
};
|
||||
|
||||
if (!doAll)
|
||||
{
|
||||
styleIndicators[0] = indiStyle;
|
||||
styleIndicators[1] = -1;
|
||||
}
|
||||
|
||||
// vector of pairs: starting position of styled text, and styled text
|
||||
std::vector<std::pair<int, generic_string>> styledVect;
|
||||
|
||||
const generic_string cr = TEXT("\r");
|
||||
const generic_string lf = TEXT("\n");
|
||||
|
||||
bool textContainsLineEndingChar = false;
|
||||
|
||||
for (int si = 0; styleIndicators[si] != -1; ++si)
|
||||
{
|
||||
int pos = static_cast<int>(execute(SCI_INDICATOREND, styleIndicators[si], 0));
|
||||
if (pos > 0)
|
||||
{
|
||||
bool atEndOfIndic = execute(SCI_INDICATORVALUEAT, styleIndicators[si], 0) != 0;
|
||||
int prevPos = pos;
|
||||
if (atEndOfIndic) prevPos = 0;
|
||||
|
||||
do
|
||||
{
|
||||
if (atEndOfIndic)
|
||||
{
|
||||
generic_string styledText = getGenericTextAsString(prevPos, pos);
|
||||
if (!textContainsLineEndingChar)
|
||||
{
|
||||
if (styledText.find(cr) != std::string::npos ||
|
||||
styledText.find(lf) != std::string::npos)
|
||||
{
|
||||
textContainsLineEndingChar = true;
|
||||
}
|
||||
}
|
||||
styledVect.push_back(::make_pair(prevPos, styledText));
|
||||
}
|
||||
atEndOfIndic = !atEndOfIndic;
|
||||
prevPos = pos;
|
||||
pos = static_cast<int>(execute(SCI_INDICATOREND, styleIndicators[si], pos));
|
||||
} while (pos != prevPos);
|
||||
}
|
||||
}
|
||||
|
||||
if (styledVect.size() > 0)
|
||||
{
|
||||
if (doAll)
|
||||
{
|
||||
// sort by starting position of styled text
|
||||
std::sort(styledVect.begin(), styledVect.end());
|
||||
}
|
||||
|
||||
const generic_string delim =
|
||||
(textContainsLineEndingChar && styledVect.size() > 1) ?
|
||||
TEXT("\r\n----\r\n") : TEXT("\r\n");
|
||||
|
||||
generic_string joined;
|
||||
for (auto item : styledVect)
|
||||
{
|
||||
joined += delim + item.second;
|
||||
}
|
||||
joined = joined.substr(delim.length());
|
||||
if (styledVect.size() > 1)
|
||||
{
|
||||
joined += TEXT("\r\n");
|
||||
}
|
||||
|
||||
str2Clipboard(joined, NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -620,6 +620,8 @@ public:
|
|||
void changeTextDirection(bool isRTL);
|
||||
bool isTextDirectionRTL() const;
|
||||
void setPositionRestoreNeeded(bool val) { _positionRestoreNeeded = val; };
|
||||
void markedTextToClipboard(int indiStyle, bool doAll = false);
|
||||
|
||||
protected:
|
||||
static HINSTANCE _hLib;
|
||||
static int _refCount;
|
||||
|
|
|
@ -69,7 +69,8 @@ MenuPosition menuPos[] = {
|
|||
{ 2, 19, -1, "search-unmarkAll" },
|
||||
{ 2, 20, -1, "search-jumpUp" },
|
||||
{ 2, 21, -1, "search-jumpDown" },
|
||||
{ 2, 23, -1, "search-bookmark" },
|
||||
{ 2, 22, -1, "search-copyStyledText" },
|
||||
{ 2, 24, -1, "search-bookmark" },
|
||||
|
||||
{ 3, 4, -1, "view-currentFileIn" },
|
||||
{ 3, 6, -1, "view-showSymbol" },
|
||||
|
|
|
@ -168,7 +168,6 @@
|
|||
#define IDM_EDIT_FULLPATHTOCLIP (IDM_EDIT + 29)
|
||||
#define IDM_EDIT_FILENAMETOCLIP (IDM_EDIT + 30)
|
||||
#define IDM_EDIT_CURRENTDIRTOCLIP (IDM_EDIT + 31)
|
||||
#define IDM_EDIT_MARKEDTOCLIP (IDM_EDIT + 79)
|
||||
|
||||
// Menu macro
|
||||
#define IDM_MACRO_RUNMULTIMACRODLG (IDM_EDIT + 32)
|
||||
|
@ -252,7 +251,15 @@
|
|||
#define IDM_SEARCH_FINDCHARINRANGE (IDM_SEARCH + 52)
|
||||
#define IDM_SEARCH_SELECTMATCHINGBRACES (IDM_SEARCH + 53)
|
||||
#define IDM_SEARCH_MARK (IDM_SEARCH + 54)
|
||||
|
||||
|
||||
#define IDM_SEARCH_STYLE1TOCLIP (IDM_SEARCH + 55)
|
||||
#define IDM_SEARCH_STYLE2TOCLIP (IDM_SEARCH + 56)
|
||||
#define IDM_SEARCH_STYLE3TOCLIP (IDM_SEARCH + 57)
|
||||
#define IDM_SEARCH_STYLE4TOCLIP (IDM_SEARCH + 58)
|
||||
#define IDM_SEARCH_STYLE5TOCLIP (IDM_SEARCH + 59)
|
||||
#define IDM_SEARCH_ALLSTYLESTOCLIP (IDM_SEARCH + 60)
|
||||
#define IDM_SEARCH_MARKEDTOCLIP (IDM_SEARCH + 61)
|
||||
|
||||
#define IDM_MISC (IDM + 3500)
|
||||
#define IDM_FILESWITCHER_FILESCLOSE (IDM_MISC + 1)
|
||||
#define IDM_FILESWITCHER_FILESCLOSEOTHERS (IDM_MISC + 2)
|
||||
|
|
Loading…
Reference in New Issue