[NEW_FEATURE] New feature: auto-complete matched delimiters.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1111 f5eea248-9336-0410-98b8-ebc06183d4e3
remotes/trunk
Don Ho 11 years ago
parent eeebf23793
commit b0ad8cae02

@ -4024,7 +4024,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
if (open != -1 && close != -1)
{
_nppGUI._matchedPairConf._matchedPairs.push_back(pair<char, char>(char(open), char(close)));
_nppGUI._matchedPairConf._matchedPairsInit.push_back(pair<char, char>(char(open), char(close)));
}
}
}

@ -677,6 +677,7 @@ private:
struct MatchedPairConf {
vector< pair<char, char> > _matchedPairs;
vector< pair<char, char> > _matchedPairsInit; // used only on init
bool _doHtmlXmlTag;
bool _doParentheses;
bool _doBrackets;

@ -2295,10 +2295,25 @@ BOOL CALLBACK AutoCompletionDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM
}
::SendDlgItemMessage(_hSelf, IDD_AUTOCPARENTHESES_CHECK, BM_SETCHECK, nppGUI._matchedPairConf._doParentheses?BST_CHECKED:BST_UNCHECKED, 0);
if (nppGUI._matchedPairConf._doParentheses)
::SendDlgItemMessage(_hSelf, IDD_AUTOCPARENTHESES_CHECK, WM_SETTEXT, 0, (LPARAM)TEXT(" ( )"));
::SendDlgItemMessage(_hSelf, IDD_AUTOCBRACKET_CHECK, BM_SETCHECK, nppGUI._matchedPairConf._doBrackets?BST_CHECKED:BST_UNCHECKED, 0);
if (nppGUI._matchedPairConf._doBrackets)
::SendDlgItemMessage(_hSelf, IDD_AUTOCBRACKET_CHECK, WM_SETTEXT, 0, (LPARAM)TEXT(" [ ]"));
::SendDlgItemMessage(_hSelf, IDD_AUTOCCURLYBRACKET_CHECK, BM_SETCHECK, nppGUI._matchedPairConf._doCurlyBrackets?BST_CHECKED:BST_UNCHECKED, 0);
if (nppGUI._matchedPairConf._doCurlyBrackets)
::SendDlgItemMessage(_hSelf, IDD_AUTOCCURLYBRACKET_CHECK, WM_SETTEXT, 0, (LPARAM)TEXT(" { }"));
::SendDlgItemMessage(_hSelf, IDD_AUTOC_QUOTESCHECK, BM_SETCHECK, nppGUI._matchedPairConf._doQuotes?BST_CHECKED:BST_UNCHECKED, 0);
if (nppGUI._matchedPairConf._doQuotes)
::SendDlgItemMessage(_hSelf, IDD_AUTOC_QUOTESCHECK, WM_SETTEXT, 0, (LPARAM)TEXT(" ' '"));
::SendDlgItemMessage(_hSelf, IDD_AUTOC_DOUBLEQUOTESCHECK, BM_SETCHECK, nppGUI._matchedPairConf._doDoubleQuotes?BST_CHECKED:BST_UNCHECKED, 0);
if (nppGUI._matchedPairConf._doDoubleQuotes)
::SendDlgItemMessage(_hSelf, IDD_AUTOC_DOUBLEQUOTESCHECK, WM_SETTEXT, 0, (LPARAM)TEXT(" \" \""));
::SendDlgItemMessage(_hSelf, IDD_AUTOCTAG_CHECK, BM_SETCHECK, nppGUI._matchedPairConf._doHtmlXmlTag?BST_CHECKED:BST_UNCHECKED, 0);
::SendDlgItemMessage(_hSelf, IDC_MACHEDPAIROPEN_EDIT1, EM_LIMITTEXT, 1, 0);
@ -2308,16 +2323,16 @@ BOOL CALLBACK AutoCompletionDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM
::SendDlgItemMessage(_hSelf, IDC_MACHEDPAIROPEN_EDIT3, EM_LIMITTEXT, 1, 0);
::SendDlgItemMessage(_hSelf, IDC_MACHEDPAIRCLOSE_EDIT3, EM_LIMITTEXT, 1, 0);
size_t nbMatchedPair = nppGUI._matchedPairConf._matchedPairs.size();
size_t nbMatchedPair = nppGUI._matchedPairConf._matchedPairsInit.size();
if (nbMatchedPair > 3)
nbMatchedPair = 3;
for (size_t i = 0; i < nbMatchedPair; ++i)
{
TCHAR openChar[2];
openChar[0] = nppGUI._matchedPairConf._matchedPairs[i].first;
openChar[0] = nppGUI._matchedPairConf._matchedPairsInit[i].first;
openChar[1] = '\0';
TCHAR closeChar[2];
closeChar[0] = nppGUI._matchedPairConf._matchedPairs[i].second;
closeChar[0] = nppGUI._matchedPairConf._matchedPairsInit[i].second;
closeChar[1] = '\0';
if (i == 0)
@ -2449,31 +2464,42 @@ BOOL CALLBACK AutoCompletionDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM
}
case IDD_AUTOCPARENTHESES_CHECK :
{
nppGUI._matchedPairConf._doParentheses = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDD_AUTOCPARENTHESES_CHECK, BM_GETCHECK, 0, 0));
return TRUE;
}
case IDD_AUTOCBRACKET_CHECK :
{
nppGUI._matchedPairConf._doBrackets = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDD_AUTOCBRACKET_CHECK, BM_GETCHECK, 0, 0));
return TRUE;
}
case IDD_AUTOCCURLYBRACKET_CHECK :
{
nppGUI._matchedPairConf._doCurlyBrackets = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDD_AUTOCCURLYBRACKET_CHECK, BM_GETCHECK, 0, 0));
return TRUE;
}
case IDD_AUTOC_DOUBLEQUOTESCHECK :
{
nppGUI._matchedPairConf._doDoubleQuotes = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDD_AUTOC_DOUBLEQUOTESCHECK, BM_GETCHECK, 0, 0));
return TRUE;
}
case IDD_AUTOC_QUOTESCHECK :
{
nppGUI._matchedPairConf._doQuotes = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDD_AUTOC_QUOTESCHECK, BM_GETCHECK, 0, 0));
bool isChecked = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, wParam, BM_GETCHECK, 0, 0));
TCHAR *label;
if (wParam == IDD_AUTOCPARENTHESES_CHECK)
{
nppGUI._matchedPairConf._doParentheses = isChecked;
label = isChecked?TEXT(" ( )"):TEXT(" (");
}
else if (wParam == IDD_AUTOCBRACKET_CHECK)
{
nppGUI._matchedPairConf._doBrackets = isChecked;
label = isChecked?TEXT(" [ ]"):TEXT(" [");
}
else if (wParam == IDD_AUTOCCURLYBRACKET_CHECK)
{
nppGUI._matchedPairConf._doCurlyBrackets = isChecked;
label = isChecked?TEXT(" { }"):TEXT(" {");
}
else if (wParam == IDD_AUTOC_DOUBLEQUOTESCHECK)
{
nppGUI._matchedPairConf._doDoubleQuotes = isChecked;
label = isChecked?TEXT(" \" \""):TEXT(" \"");
}
else // if (wParam == IDD_AUTOC_QUOTESCHECK)
{
nppGUI._matchedPairConf._doQuotes = isChecked;
label = isChecked?TEXT(" ' '"):TEXT(" '");
}
::SendDlgItemMessage(_hSelf, wParam, WM_SETTEXT, 0, (LPARAM)label);
return TRUE;
}
case IDD_AUTOCTAG_CHECK :
{
nppGUI._matchedPairConf._doHtmlXmlTag = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDD_AUTOCTAG_CHECK, BM_GETCHECK, 0, 0));

Loading…
Cancel
Save