Add option to skip numbers during word completion
Closes #2365, Closes #2378
This commit is contained in:
parent
a59f49a992
commit
98a246c1e5
|
@ -774,6 +774,7 @@
|
|||
<Item id="6809" name="Function completion"/>
|
||||
<Item id="6810" name="Word completion"/>
|
||||
<Item id="6816" name="Function and word completion"/>
|
||||
<Item id="6824" name="Ignore numbers"/>
|
||||
<Item id="6811" name="From"/>
|
||||
<Item id="6813" name="th character"/>
|
||||
<Item id="6814" name="Valid value: 1 - 9"/>
|
||||
|
|
|
@ -767,6 +767,7 @@
|
|||
<Item id="6809" name="Function completion"/>
|
||||
<Item id="6810" name="Word completion"/>
|
||||
<Item id="6816" name="Function and word completion"/>
|
||||
<Item id="6824" name="Ignore numbers"/>
|
||||
<Item id="6811" name="From"/>
|
||||
<Item id="6813" name="th character"/>
|
||||
<Item id="6814" name="Valid value: 1 - 9"/>
|
||||
|
|
|
@ -4555,8 +4555,12 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
|
|||
if (element->Attribute(TEXT("triggerFromNbChar"), &i))
|
||||
_nppGUI._autocFromLen = i;
|
||||
|
||||
const TCHAR * funcParams = element->Attribute(TEXT("funcParams"));
|
||||
if (funcParams && !lstrcmp(funcParams, TEXT("yes")))
|
||||
const TCHAR * optName = element->Attribute(TEXT("autoCIgnoreNumbers"));
|
||||
if (optName && !lstrcmp(optName, TEXT("yes")))
|
||||
_nppGUI._autocIgnoreNumbers = true;
|
||||
|
||||
optName = element->Attribute(TEXT("funcParams"));
|
||||
if (optName && !lstrcmp(optName, TEXT("yes")))
|
||||
_nppGUI._funcParams = true;
|
||||
}
|
||||
else if (!lstrcmp(nm, TEXT("auto-insert")))
|
||||
|
@ -5476,7 +5480,11 @@ bool NppParameters::writeGUIParams()
|
|||
autocExist = true;
|
||||
element->SetAttribute(TEXT("autoCAction"), _nppGUI._autocStatus);
|
||||
element->SetAttribute(TEXT("triggerFromNbChar"), static_cast<int32_t>(_nppGUI._autocFromLen));
|
||||
const TCHAR * pStr = _nppGUI._funcParams?TEXT("yes"):TEXT("no");
|
||||
|
||||
const TCHAR * pStr = _nppGUI._autocIgnoreNumbers?TEXT("yes"):TEXT("no");
|
||||
element->SetAttribute(TEXT("autoCIgnoreNumbers"), pStr);
|
||||
|
||||
pStr = _nppGUI._funcParams?TEXT("yes"):TEXT("no");
|
||||
element->SetAttribute(TEXT("funcParams"), pStr);
|
||||
}
|
||||
else if (!lstrcmp(nm, TEXT("auto-insert")))
|
||||
|
@ -5780,7 +5788,11 @@ bool NppParameters::writeGUIParams()
|
|||
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("auto-completion"));
|
||||
GUIConfigElement->SetAttribute(TEXT("autoCAction"), _nppGUI._autocStatus);
|
||||
GUIConfigElement->SetAttribute(TEXT("triggerFromNbChar"), static_cast<int32_t>(_nppGUI._autocFromLen));
|
||||
const TCHAR * pStr = _nppGUI._funcParams?TEXT("yes"):TEXT("no");
|
||||
|
||||
const TCHAR * pStr = _nppGUI._autocIgnoreNumbers?TEXT("yes"):TEXT("no");
|
||||
GUIConfigElement->SetAttribute(TEXT("autoCIgnoreNumbers"), pStr);
|
||||
|
||||
pStr = _nppGUI._funcParams?TEXT("yes"):TEXT("no");
|
||||
GUIConfigElement->SetAttribute(TEXT("funcParams"), pStr);
|
||||
}
|
||||
|
||||
|
|
|
@ -784,6 +784,7 @@ struct NppGUI final
|
|||
enum AutocStatus{autoc_none, autoc_func, autoc_word, autoc_both};
|
||||
AutocStatus _autocStatus = autoc_both;
|
||||
size_t _autocFromLen = 1;
|
||||
bool _autocIgnoreNumbers = false;
|
||||
bool _funcParams = false;
|
||||
MatchedPairConf _matchedPairConf;
|
||||
|
||||
|
|
|
@ -39,7 +39,12 @@ static bool isInList(generic_string word, const vector<generic_string> & wordArr
|
|||
if (wordArray[i] == word)
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
static bool isAllDigits(const generic_string &str)
|
||||
{
|
||||
return std::all_of(str.begin(), str.end(), ::isdigit);
|
||||
}
|
||||
|
||||
|
||||
bool AutoCompletion::showApiComplete()
|
||||
|
@ -123,6 +128,10 @@ bool AutoCompletion::showApiAndWordComplete()
|
|||
void AutoCompletion::getWordArray(vector<generic_string> & wordArray, TCHAR *beginChars)
|
||||
{
|
||||
const size_t bufSize = 256;
|
||||
const NppGUI & nppGUI = NppParameters::getInstance()->getNppGUI();
|
||||
|
||||
if (nppGUI._autocIgnoreNumbers && isAllDigits(beginChars))
|
||||
return;
|
||||
|
||||
generic_string expr(TEXT("\\<"));
|
||||
expr += beginChars;
|
||||
|
|
|
@ -325,6 +325,8 @@ BEGIN
|
|||
CTEXT "1",IDD_AUTOC_STATIC_N,299,15,8,8,WS_TABSTOP
|
||||
LTEXT "th character",IDD_AUTOC_STATIC_CHAR,313,15,57,8
|
||||
LTEXT "Valid value : 1 - 9",IDD_AUTOC_STATIC_NOTE,278,25,93,8
|
||||
CONTROL "Ignore numbers",IDD_AUTOC_IGNORENUMBERS,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,278,55,80,10
|
||||
CONTROL "Function parameters hint on input",IDD_FUNC_CHECK,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,91,72,160,10
|
||||
GROUPBOX "Auto-Insert",IDD_AUTOCINSERT_GRPSTATIC,86,94,289,84,BS_CENTER
|
||||
|
|
|
@ -2574,11 +2574,15 @@ INT_PTR CALLBACK AutoCompletionDlg::run_dlgProc(UINT message, WPARAM wParam, LPA
|
|||
|
||||
::SendDlgItemMessage(_hSelf, selectedID, BM_SETCHECK, BST_CHECKED, 0);
|
||||
|
||||
if (nppGUI._autocStatus == nppGUI.autoc_word || nppGUI._autocStatus == nppGUI.autoc_both)
|
||||
::SendDlgItemMessage(_hSelf, IDD_AUTOC_IGNORENUMBERS, BM_SETCHECK, nppGUI._autocIgnoreNumbers ? BST_CHECKED : BST_UNCHECKED, 0);
|
||||
|
||||
if (!isEnableAutoC)
|
||||
{
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_FUNCRADIO), FALSE);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_WORDRADIO), FALSE);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_BOTHRADIO), FALSE);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_IGNORENUMBERS), FALSE);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_FROM), FALSE);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_N), FALSE);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_CHAR), FALSE);
|
||||
|
@ -2695,6 +2699,9 @@ INT_PTR CALLBACK AutoCompletionDlg::run_dlgProc(UINT message, WPARAM wParam, LPA
|
|||
{
|
||||
::SendDlgItemMessage(_hSelf, IDD_AUTOC_BOTHRADIO, BM_SETCHECK, BST_CHECKED, 0);
|
||||
nppGUI._autocStatus = nppGUI.autoc_both;
|
||||
|
||||
::SendDlgItemMessage(_hSelf, IDD_AUTOC_IGNORENUMBERS, BM_SETCHECK, BST_UNCHECKED, 0);
|
||||
nppGUI._autocIgnoreNumbers = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2702,10 +2709,14 @@ INT_PTR CALLBACK AutoCompletionDlg::run_dlgProc(UINT message, WPARAM wParam, LPA
|
|||
::SendDlgItemMessage(_hSelf, IDD_AUTOC_WORDRADIO, BM_SETCHECK, BST_UNCHECKED, 0);
|
||||
::SendDlgItemMessage(_hSelf, IDD_AUTOC_BOTHRADIO, BM_SETCHECK, BST_UNCHECKED, 0);
|
||||
nppGUI._autocStatus = nppGUI.autoc_none;
|
||||
|
||||
::SendDlgItemMessage(_hSelf, IDD_AUTOC_IGNORENUMBERS, BM_SETCHECK, BST_UNCHECKED, 0);
|
||||
nppGUI._autocIgnoreNumbers = false;
|
||||
}
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_FUNCRADIO), isEnableAutoC);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_WORDRADIO), isEnableAutoC);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_BOTHRADIO), isEnableAutoC);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_IGNORENUMBERS), isEnableAutoC);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_FROM), isEnableAutoC);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_N), isEnableAutoC);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_CHAR), isEnableAutoC);
|
||||
|
@ -2716,18 +2727,31 @@ INT_PTR CALLBACK AutoCompletionDlg::run_dlgProc(UINT message, WPARAM wParam, LPA
|
|||
case IDD_AUTOC_FUNCRADIO :
|
||||
{
|
||||
nppGUI._autocStatus = nppGUI.autoc_func;
|
||||
|
||||
::SendDlgItemMessage(_hSelf, IDD_AUTOC_IGNORENUMBERS, BM_SETCHECK, BST_UNCHECKED, 0);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_IGNORENUMBERS), FALSE);
|
||||
nppGUI._autocIgnoreNumbers = false;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case IDD_AUTOC_WORDRADIO :
|
||||
{
|
||||
nppGUI._autocStatus = nppGUI.autoc_word;
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_IGNORENUMBERS), TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case IDD_AUTOC_BOTHRADIO :
|
||||
{
|
||||
nppGUI._autocStatus = nppGUI.autoc_both;
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_IGNORENUMBERS), TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case IDD_AUTOC_IGNORENUMBERS:
|
||||
{
|
||||
nppGUI._autocIgnoreNumbers = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDD_AUTOC_IGNORENUMBERS, BM_GETCHECK, 0, 0));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -315,6 +315,7 @@
|
|||
#define IDD_BACKUPDIR_RESTORESESSION_STATIC2 (IDD_PREFERENCE_BACKUP_BOX + 21)
|
||||
#define IDD_BACKUPDIR_RESTORESESSION_PATHLABEL_STATIC (IDD_PREFERENCE_BACKUP_BOX + 22)
|
||||
#define IDD_BACKUPDIR_RESTORESESSION_PATH_EDIT (IDD_PREFERENCE_BACKUP_BOX + 23)
|
||||
#define IDD_AUTOC_IGNORENUMBERS (IDD_PREFERENCE_BACKUP_BOX + 24)
|
||||
|
||||
#define IDD_PREFERENCE_AUTOCOMPLETION_BOX 6850 //(IDD_PREFERENCE_BOX + 850)
|
||||
#define IDD_AUTOCINSERT_GRPSTATIC (IDD_PREFERENCE_AUTOCOMPLETION_BOX + 1)
|
||||
|
|
Loading…
Reference in New Issue