From 8fe56ada57a90cb2f5d0d09405b2aae139412c5d Mon Sep 17 00:00:00 2001 From: Don Ho Date: Thu, 1 Aug 2013 18:50:39 +0000 Subject: [PATCH] [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 --- PowerEditor/src/Notepad_plus.cpp | 4 ++- PowerEditor/src/Notepad_plus.rc | 1 + PowerEditor/src/NppCommands.cpp | 9 ++++++- PowerEditor/src/Parameters.cpp | 1 + PowerEditor/src/localization.cpp | 44 +++++--------------------------- PowerEditor/src/menuCmdID.h | 3 ++- 6 files changed, 21 insertions(+), 41 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index c7837032c..bb371f9f1 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -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); } diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc index ffe61e327..3ccb39462 100644 --- a/PowerEditor/src/Notepad_plus.rc +++ b/PowerEditor/src/Notepad_plus.rc @@ -328,6 +328,7 @@ BEGIN MENUITEM "Previous Search Result", IDM_SEARCH_GOTOPREVFOUND MENUITEM "&Go to...", IDM_SEARCH_GOTOLINE MENUITEM "Go to Matching Brace", IDM_SEARCH_GOTOMATCHINGBRACE + MENUITEM "Select All Between Matching Braces" IDM_SEARCH_SELECTMATCHINGBRACES MENUITEM SEPARATOR POPUP "Mark All" diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 8f2e18ebe..d1f42e759 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -748,13 +748,19 @@ void Notepad_plus::command(int id) } case IDM_SEARCH_GOTOMATCHINGBRACE : + case IDM_SEARCH_SELECTMATCHINGBRACES : { int braceAtCaret = -1; int braceOpposite = -1; findMatchingBracePos(braceAtCaret, braceOpposite); 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; } @@ -2439,6 +2445,7 @@ void Notepad_plus::command(int id) case IDM_SEARCH_SETANDFINDNEXT : case IDM_SEARCH_SETANDFINDPREV : case IDM_SEARCH_GOTOMATCHINGBRACE : + case IDM_SEARCH_SELECTMATCHINGBRACES : case IDM_SEARCH_TOGGLE_BOOKMARK : case IDM_SEARCH_NEXT_BOOKMARK: case IDM_SEARCH_PREV_BOOKMARK: diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 1425b87b6..3bd57fa6f 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -136,6 +136,7 @@ WinMenuKeyDefinition winKeyDefs[] = { {VK_I, IDM_SEARCH_FINDINCREMENT, true, true, false, NULL}, {VK_G, IDM_SEARCH_GOTOLINE, 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_NEXT_BOOKMARK, false, false, false, NULL}, {VK_F2, IDM_SEARCH_PREV_BOOKMARK, false, false, true, NULL}, diff --git a/PowerEditor/src/localization.cpp b/PowerEditor/src/localization.cpp index bcd600754..ab93b0f47 100644 --- a/PowerEditor/src/localization.cpp +++ b/PowerEditor/src/localization.cpp @@ -185,11 +185,11 @@ MenuPosition menuPos[] = { { 1, 17, -1, "edit-blankOperations"}, { 1, 18, -1, "edit-pasteSpecial"}, - { 2, 16, -1, "search-markAll"}, - { 2, 17, -1, "search-unmarkAll"}, - { 2, 18, -1, "search-jumpUp"}, - { 2, 19, -1, "search-jumpDown"}, - { 2, 21, -1, "search-bookmark"}, + { 2, 17, -1, "search-markAll"}, + { 2, 18, -1, "search-unmarkAll"}, + { 2, 19, -1, "search-jumpUp"}, + { 2, 20, -1, "search-jumpDown"}, + { 2, 22, -1, "search-bookmark"}, { 3, 4, -1, "view-showSymbol"}, { 3, 5, -1, "view-zoom"}, @@ -698,39 +698,7 @@ void NativeLangSpeaker::changeUserDefineLang(UserDefineDialog *userDefineDlg) hDlgArrary[1] = userDefineDlg->getKeywordsHandle(); hDlgArrary[2] = userDefineDlg->getCommentHandle(); 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"}; for (int i = 0 ; i < nbDlg ; ++i) diff --git a/PowerEditor/src/menuCmdID.h b/PowerEditor/src/menuCmdID.h index 30d44bc9f..0f4cd3fb8 100644 --- a/PowerEditor/src/menuCmdID.h +++ b/PowerEditor/src/menuCmdID.h @@ -185,7 +185,8 @@ #define IDM_SEARCH_INVERSEMARKS (IDM_SEARCH + 50) #define IDM_SEARCH_DELETEUNMARKEDLINES (IDM_SEARCH + 51) #define IDM_SEARCH_FINDCHARINRANGE (IDM_SEARCH + 52) - + #define IDM_SEARCH_SELECTMATCHINGBRACES (IDM_SEARCH + 53) + #define IDM_MISC (IDM + 3500) #define IDM_FILESWITCHER_FILESCLOSE (IDM_MISC + 1) #define IDM_FILESWITCHER_FILESCLOSEOTHERS (IDM_MISC + 2)