parent
1efac7dacb
commit
ca3d514722
|
@ -120,6 +120,7 @@
|
||||||
<Item id="42064" name="Sort Lines As Decimals (Comma) Descending"/>
|
<Item id="42064" name="Sort Lines As Decimals (Comma) Descending"/>
|
||||||
<Item id="42065" name="Sort Lines As Decimals (Dot) Ascending"/>
|
<Item id="42065" name="Sort Lines As Decimals (Dot) Ascending"/>
|
||||||
<Item id="42066" name="Sort Lines As Decimals (Dot) Descending"/>
|
<Item id="42066" name="Sort Lines As Decimals (Dot) Descending"/>
|
||||||
|
<Item id="42078" name="Sort Lines Randomly"/>
|
||||||
<Item id="42016" name="&UPPERCASE"/>
|
<Item id="42016" name="&UPPERCASE"/>
|
||||||
<Item id="42017" name="&lowercase"/>
|
<Item id="42017" name="&lowercase"/>
|
||||||
<Item id="42067" name="&Proper Case"/>
|
<Item id="42067" name="&Proper Case"/>
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <random>
|
||||||
|
|
||||||
// Base interface for line sorting.
|
// Base interface for line sorting.
|
||||||
class ISorter
|
class ISorter
|
||||||
|
@ -385,4 +386,19 @@ protected:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class RandomSorter : public ISorter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
unsigned seed;
|
||||||
|
RandomSorter(bool isDescending, size_t fromColumn, size_t toColumn) : ISorter(isDescending, fromColumn, toColumn)
|
||||||
|
{
|
||||||
|
seed = static_cast<unsigned>(time(NULL));
|
||||||
|
}
|
||||||
|
std::vector<generic_string> sort(std::vector<generic_string> lines) override
|
||||||
|
{
|
||||||
|
std::shuffle(lines.begin(), lines.end(), std::default_random_engine(seed));
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
#endif //NPP_SORTERS_H
|
#endif //NPP_SORTERS_H
|
||||||
|
|
|
@ -322,6 +322,8 @@ BEGIN
|
||||||
MENUITEM "Sort Lines As Integers Descending", IDM_EDIT_SORTLINES_INTEGER_DESCENDING
|
MENUITEM "Sort Lines As Integers Descending", IDM_EDIT_SORTLINES_INTEGER_DESCENDING
|
||||||
MENUITEM "Sort Lines As Decimals (Comma) Descending", IDM_EDIT_SORTLINES_DECIMALCOMMA_DESCENDING
|
MENUITEM "Sort Lines As Decimals (Comma) Descending", IDM_EDIT_SORTLINES_DECIMALCOMMA_DESCENDING
|
||||||
MENUITEM "Sort Lines As Decimals (Dot) Descending", IDM_EDIT_SORTLINES_DECIMALDOT_DESCENDING
|
MENUITEM "Sort Lines As Decimals (Dot) Descending", IDM_EDIT_SORTLINES_DECIMALDOT_DESCENDING
|
||||||
|
MENUITEM SEPARATOR
|
||||||
|
MENUITEM "Sort Lines Randomly", IDM_EDIT_SORTLINES_RANDOMLY
|
||||||
END
|
END
|
||||||
POPUP "Comment/Uncomment"
|
POPUP "Comment/Uncomment"
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
|
@ -550,6 +550,7 @@ void Notepad_plus::command(int id)
|
||||||
case IDM_EDIT_SORTLINES_DECIMALCOMMA_DESCENDING:
|
case IDM_EDIT_SORTLINES_DECIMALCOMMA_DESCENDING:
|
||||||
case IDM_EDIT_SORTLINES_DECIMALDOT_ASCENDING:
|
case IDM_EDIT_SORTLINES_DECIMALDOT_ASCENDING:
|
||||||
case IDM_EDIT_SORTLINES_DECIMALDOT_DESCENDING:
|
case IDM_EDIT_SORTLINES_DECIMALDOT_DESCENDING:
|
||||||
|
case IDM_EDIT_SORTLINES_RANDOMLY:
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(command_mutex);
|
std::lock_guard<std::mutex> lock(command_mutex);
|
||||||
|
|
||||||
|
@ -619,10 +620,14 @@ void Notepad_plus::command(int id)
|
||||||
{
|
{
|
||||||
pSorter = std::unique_ptr<ISorter>(new DecimalCommaSorter(isDescending, fromColumn, toColumn));
|
pSorter = std::unique_ptr<ISorter>(new DecimalCommaSorter(isDescending, fromColumn, toColumn));
|
||||||
}
|
}
|
||||||
else
|
else if (id == IDM_EDIT_SORTLINES_DECIMALDOT_DESCENDING || id == IDM_EDIT_SORTLINES_DECIMALDOT_ASCENDING)
|
||||||
{
|
{
|
||||||
pSorter = std::unique_ptr<ISorter>(new DecimalDotSorter(isDescending, fromColumn, toColumn));
|
pSorter = std::unique_ptr<ISorter>(new DecimalDotSorter(isDescending, fromColumn, toColumn));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pSorter = std::unique_ptr<ISorter>(new RandomSorter(isDescending, fromColumn, toColumn));
|
||||||
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_pEditView->sortLines(fromLine, toLine, pSorter.get());
|
_pEditView->sortLines(fromLine, toLine, pSorter.get());
|
||||||
|
@ -3449,6 +3454,7 @@ void Notepad_plus::command(int id)
|
||||||
case IDM_EDIT_SORTLINES_DECIMALCOMMA_DESCENDING:
|
case IDM_EDIT_SORTLINES_DECIMALCOMMA_DESCENDING:
|
||||||
case IDM_EDIT_SORTLINES_DECIMALDOT_ASCENDING:
|
case IDM_EDIT_SORTLINES_DECIMALDOT_ASCENDING:
|
||||||
case IDM_EDIT_SORTLINES_DECIMALDOT_DESCENDING:
|
case IDM_EDIT_SORTLINES_DECIMALDOT_DESCENDING:
|
||||||
|
case IDM_EDIT_SORTLINES_RANDOMLY:
|
||||||
case IDM_EDIT_BLANKLINEABOVECURRENT:
|
case IDM_EDIT_BLANKLINEABOVECURRENT:
|
||||||
case IDM_EDIT_BLANKLINEBELOWCURRENT:
|
case IDM_EDIT_BLANKLINEBELOWCURRENT:
|
||||||
case IDM_VIEW_FULLSCREENTOGGLE :
|
case IDM_VIEW_FULLSCREENTOGGLE :
|
||||||
|
|
|
@ -144,6 +144,7 @@ static const WinMenuKeyDefinition winKeyDefs[] =
|
||||||
{ VK_NULL, IDM_EDIT_SORTLINES_DECIMALCOMMA_DESCENDING, false, false, false, nullptr },
|
{ VK_NULL, IDM_EDIT_SORTLINES_DECIMALCOMMA_DESCENDING, false, false, false, nullptr },
|
||||||
{ VK_NULL, IDM_EDIT_SORTLINES_DECIMALDOT_ASCENDING, false, false, false, nullptr },
|
{ VK_NULL, IDM_EDIT_SORTLINES_DECIMALDOT_ASCENDING, false, false, false, nullptr },
|
||||||
{ VK_NULL, IDM_EDIT_SORTLINES_DECIMALDOT_DESCENDING, false, false, false, nullptr },
|
{ VK_NULL, IDM_EDIT_SORTLINES_DECIMALDOT_DESCENDING, false, false, false, nullptr },
|
||||||
|
{ VK_NULL, IDM_EDIT_SORTLINES_RANDOMLY, false, false, false, nullptr },
|
||||||
{ VK_Q, IDM_EDIT_BLOCK_COMMENT, true, false, false, nullptr },
|
{ VK_Q, IDM_EDIT_BLOCK_COMMENT, true, false, false, nullptr },
|
||||||
{ VK_K, IDM_EDIT_BLOCK_COMMENT_SET, true, false, false, nullptr },
|
{ VK_K, IDM_EDIT_BLOCK_COMMENT_SET, true, false, false, nullptr },
|
||||||
{ VK_K, IDM_EDIT_BLOCK_UNCOMMENT, true, false, true, nullptr },
|
{ VK_K, IDM_EDIT_BLOCK_UNCOMMENT, true, false, true, nullptr },
|
||||||
|
|
|
@ -130,6 +130,7 @@
|
||||||
#define IDM_EDIT_SORTLINES_DECIMALCOMMA_DESCENDING (IDM_EDIT + 64)
|
#define IDM_EDIT_SORTLINES_DECIMALCOMMA_DESCENDING (IDM_EDIT + 64)
|
||||||
#define IDM_EDIT_SORTLINES_DECIMALDOT_ASCENDING (IDM_EDIT + 65)
|
#define IDM_EDIT_SORTLINES_DECIMALDOT_ASCENDING (IDM_EDIT + 65)
|
||||||
#define IDM_EDIT_SORTLINES_DECIMALDOT_DESCENDING (IDM_EDIT + 66)
|
#define IDM_EDIT_SORTLINES_DECIMALDOT_DESCENDING (IDM_EDIT + 66)
|
||||||
|
#define IDM_EDIT_SORTLINES_RANDOMLY (IDM_EDIT + 78)
|
||||||
|
|
||||||
#define IDM_EDIT_OPENASFILE (IDM_EDIT + 73)
|
#define IDM_EDIT_OPENASFILE (IDM_EDIT + 73)
|
||||||
#define IDM_EDIT_OPENINFOLDER (IDM_EDIT + 74)
|
#define IDM_EDIT_OPENINFOLDER (IDM_EDIT + 74)
|
||||||
|
|
Loading…
Reference in New Issue