[NEW_FEATURE] (Author: Andreas Jonsson) Add new feature: select all between matching braces.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1093 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2013-08-01 18:50:39 +00:00
parent c866075f58
commit 8fe56ada57
6 changed files with 20 additions and 40 deletions

View File

@ -2038,7 +2038,9 @@ bool Notepad_plus::braceMatch()
} }
} }
enableCommand(IDM_SEARCH_GOTOMATCHINGBRACE, (braceAtCaret != -1) && (braceOpposite != -1), MENU | TOOLBAR); const bool enable = (braceAtCaret != -1) && (braceOpposite != -1);
enableCommand(IDM_SEARCH_GOTOMATCHINGBRACE, enable, MENU | TOOLBAR);
enableCommand(IDM_SEARCH_SELECTMATCHINGBRACES, enable, MENU);
return (braceAtCaret != -1); return (braceAtCaret != -1);
} }

View File

@ -328,6 +328,7 @@ BEGIN
MENUITEM "Previous Search Result", IDM_SEARCH_GOTOPREVFOUND MENUITEM "Previous Search Result", IDM_SEARCH_GOTOPREVFOUND
MENUITEM "&Go to...", IDM_SEARCH_GOTOLINE MENUITEM "&Go to...", IDM_SEARCH_GOTOLINE
MENUITEM "Go to Matching Brace", IDM_SEARCH_GOTOMATCHINGBRACE MENUITEM "Go to Matching Brace", IDM_SEARCH_GOTOMATCHINGBRACE
MENUITEM "Select All Between Matching Braces" IDM_SEARCH_SELECTMATCHINGBRACES
MENUITEM SEPARATOR MENUITEM SEPARATOR
POPUP "Mark All" POPUP "Mark All"

View File

@ -748,13 +748,19 @@ void Notepad_plus::command(int id)
} }
case IDM_SEARCH_GOTOMATCHINGBRACE : case IDM_SEARCH_GOTOMATCHINGBRACE :
case IDM_SEARCH_SELECTMATCHINGBRACES :
{ {
int braceAtCaret = -1; int braceAtCaret = -1;
int braceOpposite = -1; int braceOpposite = -1;
findMatchingBracePos(braceAtCaret, braceOpposite); findMatchingBracePos(braceAtCaret, braceOpposite);
if (braceOpposite != -1) if (braceOpposite != -1)
_pEditView->execute(SCI_GOTOPOS, braceOpposite); {
if(id == IDM_SEARCH_GOTOMATCHINGBRACE)
_pEditView->execute(SCI_GOTOPOS, braceOpposite);
else
_pEditView->execute(SCI_SETSEL, min(braceAtCaret, braceOpposite), max(braceAtCaret, braceOpposite) + 1); // + 1 so we always include the ending brace in the selection.
}
break; break;
} }
@ -2439,6 +2445,7 @@ void Notepad_plus::command(int id)
case IDM_SEARCH_SETANDFINDNEXT : case IDM_SEARCH_SETANDFINDNEXT :
case IDM_SEARCH_SETANDFINDPREV : case IDM_SEARCH_SETANDFINDPREV :
case IDM_SEARCH_GOTOMATCHINGBRACE : case IDM_SEARCH_GOTOMATCHINGBRACE :
case IDM_SEARCH_SELECTMATCHINGBRACES :
case IDM_SEARCH_TOGGLE_BOOKMARK : case IDM_SEARCH_TOGGLE_BOOKMARK :
case IDM_SEARCH_NEXT_BOOKMARK: case IDM_SEARCH_NEXT_BOOKMARK:
case IDM_SEARCH_PREV_BOOKMARK: case IDM_SEARCH_PREV_BOOKMARK:

View File

@ -136,6 +136,7 @@ WinMenuKeyDefinition winKeyDefs[] = {
{VK_I, IDM_SEARCH_FINDINCREMENT, true, true, false, NULL}, {VK_I, IDM_SEARCH_FINDINCREMENT, true, true, false, NULL},
{VK_G, IDM_SEARCH_GOTOLINE, true, false, false, NULL}, {VK_G, IDM_SEARCH_GOTOLINE, true, false, false, NULL},
{VK_B, IDM_SEARCH_GOTOMATCHINGBRACE, true, false, false, NULL}, {VK_B, IDM_SEARCH_GOTOMATCHINGBRACE, true, false, false, NULL},
{VK_B, IDM_SEARCH_SELECTMATCHINGBRACES, true, true, false, NULL},
{VK_F2, IDM_SEARCH_TOGGLE_BOOKMARK, true, false, false, NULL}, {VK_F2, IDM_SEARCH_TOGGLE_BOOKMARK, true, false, false, NULL},
{VK_F2, IDM_SEARCH_NEXT_BOOKMARK, false, false, false, NULL}, {VK_F2, IDM_SEARCH_NEXT_BOOKMARK, false, false, false, NULL},
{VK_F2, IDM_SEARCH_PREV_BOOKMARK, false, false, true, NULL}, {VK_F2, IDM_SEARCH_PREV_BOOKMARK, false, false, true, NULL},

View File

@ -185,11 +185,11 @@ MenuPosition menuPos[] = {
{ 1, 17, -1, "edit-blankOperations"}, { 1, 17, -1, "edit-blankOperations"},
{ 1, 18, -1, "edit-pasteSpecial"}, { 1, 18, -1, "edit-pasteSpecial"},
{ 2, 16, -1, "search-markAll"}, { 2, 17, -1, "search-markAll"},
{ 2, 17, -1, "search-unmarkAll"}, { 2, 18, -1, "search-unmarkAll"},
{ 2, 18, -1, "search-jumpUp"}, { 2, 19, -1, "search-jumpUp"},
{ 2, 19, -1, "search-jumpDown"}, { 2, 20, -1, "search-jumpDown"},
{ 2, 21, -1, "search-bookmark"}, { 2, 22, -1, "search-bookmark"},
{ 3, 4, -1, "view-showSymbol"}, { 3, 4, -1, "view-showSymbol"},
{ 3, 5, -1, "view-zoom"}, { 3, 5, -1, "view-zoom"},
@ -698,39 +698,7 @@ void NativeLangSpeaker::changeUserDefineLang(UserDefineDialog *userDefineDlg)
hDlgArrary[1] = userDefineDlg->getKeywordsHandle(); hDlgArrary[1] = userDefineDlg->getKeywordsHandle();
hDlgArrary[2] = userDefineDlg->getCommentHandle(); hDlgArrary[2] = userDefineDlg->getCommentHandle();
hDlgArrary[3] = userDefineDlg->getSymbolHandle(); hDlgArrary[3] = userDefineDlg->getSymbolHandle();
/*
const int nbGrpFolder = 3;
int folderID[nbGrpFolder][nbControl] = {
//{IDC_DEFAULT_COLORSTYLEGROUP_STATIC, IDC_DEFAULT_FG_STATIC, IDC_DEFAULT_BG_STATIC, IDC_DEFAULT_FONTSTYLEGROUP_STATIC, IDC_DEFAULT_FONTNAME_STATIC, IDC_DEFAULT_FONTSIZE_STATIC, IDC_DEFAULT_BOLD_CHECK, IDC_DEFAULT_ITALIC_CHECK, IDC_DEFAULT_UNDERLINE_CHECK},\
//{IDC_FOLDEROPEN_COLORSTYLEGROUP_STATIC, IDC_FOLDEROPEN_FG_STATIC, IDC_FOLDEROPEN_BG_STATIC, IDC_FOLDEROPEN_FONTSTYLEGROUP_STATIC, IDC_FOLDEROPEN_FONTNAME_STATIC, IDC_FOLDEROPEN_FONTSIZE_STATIC, IDC_FOLDEROPEN_BOLD_CHECK, IDC_FOLDEROPEN_ITALIC_CHECK, IDC_FOLDEROPEN_UNDERLINE_CHECK},\
//{IDC_FOLDERCLOSE_COLORSTYLEGROUP_STATIC, IDC_FOLDERCLOSE_FG_STATIC, IDC_FOLDERCLOSE_BG_STATIC, IDC_FOLDERCLOSE_FONTSTYLEGROUP_STATIC, IDC_FOLDERCLOSE_FONTNAME_STATIC, IDC_FOLDERCLOSE_FONTSIZE_STATIC, IDC_FOLDERCLOSE_BOLD_CHECK, IDC_FOLDERCLOSE_ITALIC_CHECK, IDC_FOLDERCLOSE_UNDERLINE_CHECK}
};
const int nbGrpKeywords = 4;
int keywordsID[nbGrpKeywords][nbControl] = {//\
//{IDC_KEYWORD1_COLORSTYLEGROUP_STATIC, IDC_KEYWORD1_FG_STATIC, IDC_KEYWORD1_BG_STATIC, IDC_KEYWORD1_FONTSTYLEGROUP_STATIC, IDC_KEYWORD1_FONTNAME_STATIC, IDC_KEYWORD1_FONTSIZE_STATIC, IDC_KEYWORD1_BOLD_CHECK, IDC_KEYWORD1_ITALIC_CHECK, IDC_KEYWORD1_UNDERLINE_CHECK},\
//{IDC_KEYWORD2_COLORSTYLEGROUP_STATIC, IDC_KEYWORD2_FG_STATIC, IDC_KEYWORD2_BG_STATIC, IDC_KEYWORD2_FONTSTYLEGROUP_STATIC, IDC_KEYWORD2_FONTNAME_STATIC, IDC_KEYWORD2_FONTSIZE_STATIC, IDC_KEYWORD2_BOLD_CHECK, IDC_KEYWORD2_ITALIC_CHECK, IDC_KEYWORD2_UNDERLINE_CHECK},\
//{IDC_KEYWORD3_COLORSTYLEGROUP_STATIC, IDC_KEYWORD3_FG_STATIC, IDC_KEYWORD3_BG_STATIC, IDC_KEYWORD3_FONTSTYLEGROUP_STATIC, IDC_KEYWORD3_FONTNAME_STATIC, IDC_KEYWORD3_FONTSIZE_STATIC, IDC_KEYWORD3_BOLD_CHECK, IDC_KEYWORD3_ITALIC_CHECK, IDC_KEYWORD3_UNDERLINE_CHECK},\
//{IDC_KEYWORD4_COLORSTYLEGROUP_STATIC, IDC_KEYWORD4_FG_STATIC, IDC_KEYWORD4_BG_STATIC, IDC_KEYWORD4_FONTSTYLEGROUP_STATIC, IDC_KEYWORD4_FONTNAME_STATIC, IDC_KEYWORD4_FONTSIZE_STATIC, IDC_KEYWORD4_BOLD_CHECK, IDC_KEYWORD4_ITALIC_CHECK, IDC_KEYWORD4_UNDERLINE_CHECK}
};
const int nbGrpComment = 3;
int commentID[nbGrpComment][nbControl] = {//\
//{IDC_COMMENT_COLORSTYLEGROUP_STATIC, IDC_COMMENT_FG_STATIC, IDC_COMMENT_BG_STATIC, IDC_COMMENT_FONTSTYLEGROUP_STATIC, IDC_COMMENT_FONTNAME_STATIC, IDC_COMMENT_FONTSIZE_STATIC, IDC_COMMENT_BOLD_CHECK, IDC_COMMENT_ITALIC_CHECK, IDC_COMMENT_UNDERLINE_CHECK},\
//{IDC_NUMBER_COLORSTYLEGROUP_STATIC, IDC_NUMBER_FG_STATIC, IDC_NUMBER_BG_STATIC, IDC_NUMBER_FONTSTYLEGROUP_STATIC, IDC_NUMBER_FONTNAME_STATIC, IDC_NUMBER_FONTSIZE_STATIC, IDC_NUMBER_BOLD_CHECK, IDC_NUMBER_ITALIC_CHECK, IDC_NUMBER_UNDERLINE_CHECK},\
//{IDC_COMMENTLINE_COLORSTYLEGROUP_STATIC, IDC_COMMENTLINE_FG_STATIC, IDC_COMMENTLINE_BG_STATIC, IDC_COMMENTLINE_FONTSTYLEGROUP_STATIC, IDC_COMMENTLINE_FONTNAME_STATIC, IDC_COMMENTLINE_FONTSIZE_STATIC, IDC_COMMENTLINE_BOLD_CHECK, IDC_COMMENTLINE_ITALIC_CHECK, IDC_COMMENTLINE_UNDERLINE_CHECK}
};
const int nbGrpOperator = 4;
int operatorID[nbGrpOperator][nbControl] = {//\
//{IDC_OPERATOR_COLORSTYLEGROUP_STATIC, IDC_OPERATOR_FG_STATIC, IDC_OPERATOR_BG_STATIC, IDC_OPERATOR_FONTSTYLEGROUP_STATIC, IDC_OPERATOR_FONTNAME_STATIC, IDC_OPERATOR_FONTSIZE_STATIC, IDC_OPERATOR_BOLD_CHECK, IDC_OPERATOR_ITALIC_CHECK, IDC_OPERATOR_UNDERLINE_CHECK},\
//{IDC_DELIMITER1_COLORSTYLEGROUP_STATIC, IDC_DELIMITER1_FG_STATIC, IDC_DELIMITER1_BG_STATIC, IDC_DELIMITER1_FONTSTYLEGROUP_STATIC, IDC_DELIMITER1_FONTNAME_STATIC, IDC_DELIMITER1_FONTSIZE_STATIC, IDC_DELIMITER1_BOLD_CHECK, IDC_DELIMITER1_ITALIC_CHECK, IDC_DELIMITER1_UNDERLINE_CHECK},\
//{IDC_DELIMITER2_COLORSTYLEGROUP_STATIC, IDC_DELIMITER2_FG_STATIC, IDC_DELIMITER2_BG_STATIC, IDC_DELIMITER2_FONTSTYLEGROUP_STATIC, IDC_DELIMITER2_FONTNAME_STATIC, IDC_DELIMITER2_FONTSIZE_STATIC, IDC_DELIMITER2_BOLD_CHECK, IDC_DELIMITER2_ITALIC_CHECK, IDC_DELIMITER2_UNDERLINE_CHECK},\
//{IDC_DELIMITER3_COLORSTYLEGROUP_STATIC, IDC_DELIMITER3_FG_STATIC, IDC_DELIMITER3_BG_STATIC, IDC_DELIMITER3_FONTSTYLEGROUP_STATIC, IDC_DELIMITER3_FONTNAME_STATIC, IDC_DELIMITER3_FONTSIZE_STATIC, IDC_DELIMITER3_BOLD_CHECK, IDC_DELIMITER3_ITALIC_CHECK, IDC_DELIMITER3_UNDERLINE_CHECK}
};
int nbGpArray[nbDlg] = {nbGrpFolder, nbGrpKeywords, nbGrpComment, nbGrpOperator};
*/
const char nodeNameArray[nbDlg][16] = {"Folder", "Keywords", "Comment", "Operator"}; const char nodeNameArray[nbDlg][16] = {"Folder", "Keywords", "Comment", "Operator"};
for (int i = 0 ; i < nbDlg ; ++i) for (int i = 0 ; i < nbDlg ; ++i)

View File

@ -185,7 +185,8 @@
#define IDM_SEARCH_INVERSEMARKS (IDM_SEARCH + 50) #define IDM_SEARCH_INVERSEMARKS (IDM_SEARCH + 50)
#define IDM_SEARCH_DELETEUNMARKEDLINES (IDM_SEARCH + 51) #define IDM_SEARCH_DELETEUNMARKEDLINES (IDM_SEARCH + 51)
#define IDM_SEARCH_FINDCHARINRANGE (IDM_SEARCH + 52) #define IDM_SEARCH_FINDCHARINRANGE (IDM_SEARCH + 52)
#define IDM_SEARCH_SELECTMATCHINGBRACES (IDM_SEARCH + 53)
#define IDM_MISC (IDM + 3500) #define IDM_MISC (IDM + 3500)
#define IDM_FILESWITCHER_FILESCLOSE (IDM_MISC + 1) #define IDM_FILESWITCHER_FILESCLOSE (IDM_MISC + 1)
#define IDM_FILESWITCHER_FILESCLOSEOTHERS (IDM_MISC + 2) #define IDM_FILESWITCHER_FILESCLOSEOTHERS (IDM_MISC + 2)