Skip to content

Commit

Permalink
Add option to only use words in current document for auto-completion,…
Browse files Browse the repository at this point in the history
… discussion #798.
  • Loading branch information
zufuliu committed Aug 4, 2024
1 parent f24cd39 commit 352a188
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 32 deletions.
4 changes: 2 additions & 2 deletions locale/de/Notepad4.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1620,8 +1620,8 @@ BEGIN
EDITTEXT IDC_AUTOC_MIN_NUMBER_LENGTH,166,48,50,12,ES_NUMBER | WS_TABSTOP
AUTOCHECKBOX "Scanning words in current document for",IDC_AUTOC_SCAN_DOCUMENT_WORDS,14,68,150,10,WS_TABSTOP
EDITTEXT IDC_AUTOC_SCAN_WORDS_TIMEOUT,166,64,50,12,WS_TABSTOP
AUTOCHECKBOX "Only trigger auto completion in English IME mode.",IDC_AUTOC_ENGLISH_IME_ONLY,14,80,180,10,WS_TABSTOP
AUTOCHECKBOX "Auto completion is case insensitive.",IDC_AUTOC_CASE_INSENSITIVE,14,92,180,10,WS_TABSTOP
AUTOCHECKBOX "Only use words in current document.",IDC_AUTOC_ONLY_DOCUMENT_WORDS,14,80,180,10,WS_TABSTOP
AUTOCHECKBOX "Only trigger auto completion in English IME mode.",IDC_AUTOC_ENGLISH_IME_ONLY,14,92,180,10,WS_TABSTOP

GROUPBOX "Auto complete word inside:",IDC_STATIC,7,111,218,26
AUTOCHECKBOX "Comment",IDC_AUTO_COMPLETE_INSIDE_COMMONT,14,123,65,10,WS_TABSTOP
Expand Down
4 changes: 2 additions & 2 deletions locale/fr/Notepad4.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1620,8 +1620,8 @@ BEGIN
EDITTEXT IDC_AUTOC_MIN_NUMBER_LENGTH,166,48,50,12,ES_NUMBER | WS_TABSTOP
AUTOCHECKBOX "Scanner les mots dans le document pour",IDC_AUTOC_SCAN_DOCUMENT_WORDS,14,68,150,10,WS_TABSTOP
EDITTEXT IDC_AUTOC_SCAN_WORDS_TIMEOUT,166,64,50,12,WS_TABSTOP
AUTOCHECKBOX "Déclencher l'auto-complémention seulement pour le mode IME anglais.",IDC_AUTOC_ENGLISH_IME_ONLY,14,80,180,10,WS_TABSTOP
AUTOCHECKBOX "L'auto-completion est insensible à la casse.",IDC_AUTOC_CASE_INSENSITIVE,14,92,180,10,WS_TABSTOP
AUTOCHECKBOX "Only use words in current document.",IDC_AUTOC_ONLY_DOCUMENT_WORDS,14,80,180,10,WS_TABSTOP
AUTOCHECKBOX "Déclencher l'auto-complémention seulement pour le mode IME anglais.",IDC_AUTOC_ENGLISH_IME_ONLY,14,92,180,10,WS_TABSTOP

GROUPBOX "Auto complete word inside:",IDC_STATIC,7,111,218,26
AUTOCHECKBOX "Comment",IDC_AUTO_COMPLETE_INSIDE_COMMONT,14,123,65,10,WS_TABSTOP
Expand Down
4 changes: 2 additions & 2 deletions locale/it/Notepad4.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1620,8 +1620,8 @@ BEGIN
EDITTEXT IDC_AUTOC_MIN_NUMBER_LENGTH,166,48,50,12,ES_NUMBER | WS_TABSTOP
AUTOCHECKBOX "Scansione delle parole nel documento ogni:",IDC_AUTOC_SCAN_DOCUMENT_WORDS,14,68,150,10,WS_TABSTOP
EDITTEXT IDC_AUTOC_SCAN_WORDS_TIMEOUT,166,64,50,12,WS_TABSTOP
AUTOCHECKBOX "Attiva il completamento solo in modalità IME inglese.",IDC_AUTOC_ENGLISH_IME_ONLY,14,80,180,10,WS_TABSTOP
AUTOCHECKBOX "Il completamento non fa distinzione tra maiuscole e minuscole.",IDC_AUTOC_CASE_INSENSITIVE,14,92,200,10,WS_TABSTOP
AUTOCHECKBOX "Only use words in current document.",IDC_AUTOC_ONLY_DOCUMENT_WORDS,14,80,180,10,WS_TABSTOP
AUTOCHECKBOX "Attiva il completamento solo in modalità IME inglese.",IDC_AUTOC_ENGLISH_IME_ONLY,14,92,200,10,WS_TABSTOP

GROUPBOX "Autocompleta parole in:",IDC_STATIC,7,111,218,26
AUTOCHECKBOX "Commenti",IDC_AUTO_COMPLETE_INSIDE_COMMONT,14,123,65,10,WS_TABSTOP
Expand Down
4 changes: 2 additions & 2 deletions locale/ja/Notepad4.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1620,8 +1620,8 @@ BEGIN
EDITTEXT IDC_AUTOC_MIN_NUMBER_LENGTH,166,48,50,12,ES_NUMBER | WS_TABSTOP
AUTOCHECKBOX "以下の時間だけ現在の文書中の単語を拾う(&S)",IDC_AUTOC_SCAN_DOCUMENT_WORDS,14,68,150,10,WS_TABSTOP
EDITTEXT IDC_AUTOC_SCAN_WORDS_TIMEOUT,166,64,50,12,WS_TABSTOP
AUTOCHECKBOX "IMEが英数の場合にだけ自動補完を行う",IDC_AUTOC_ENGLISH_IME_ONLY,14,80,180,10,WS_TABSTOP
AUTOCHECKBOX "自動補完で大・小文字を無視",IDC_AUTOC_CASE_INSENSITIVE,14,92,180,10,WS_TABSTOP
AUTOCHECKBOX "Only use words in current document.",IDC_AUTOC_ONLY_DOCUMENT_WORDS,14,80,180,10,WS_TABSTOP
AUTOCHECKBOX "IMEが英数の場合にだけ自動補完を行う",IDC_AUTOC_ENGLISH_IME_ONLY,14,92,180,10,WS_TABSTOP

GROUPBOX "以下の中の単語を自動補完:",IDC_STATIC,7,111,218,26
AUTOCHECKBOX "コメント",IDC_AUTO_COMPLETE_INSIDE_COMMONT,14,123,65,10,WS_TABSTOP
Expand Down
4 changes: 2 additions & 2 deletions locale/ko/Notepad4.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1620,8 +1620,8 @@ BEGIN
EDITTEXT IDC_AUTOC_MIN_NUMBER_LENGTH,166,48,50,12,ES_NUMBER | WS_TABSTOP
AUTOCHECKBOX "현재 문서의 단어를 검색",IDC_AUTOC_SCAN_DOCUMENT_WORDS,14,68,150,10,WS_TABSTOP
EDITTEXT IDC_AUTOC_SCAN_WORDS_TIMEOUT,166,64,50,12,WS_TABSTOP
AUTOCHECKBOX "영어 IME 모드에서만 자동 완성 작동",IDC_AUTOC_ENGLISH_IME_ONLY,14,80,180,10,WS_TABSTOP
AUTOCHECKBOX "자동 완성은 대소문자를 구분하지 않음",IDC_AUTOC_CASE_INSENSITIVE,14,92,180,10,WS_TABSTOP
AUTOCHECKBOX "Only use words in current document.",IDC_AUTOC_ONLY_DOCUMENT_WORDS,14,80,180,10,WS_TABSTOP
AUTOCHECKBOX "영어 IME 모드에서만 자동 완성 작동",IDC_AUTOC_ENGLISH_IME_ONLY,14,92,180,10,WS_TABSTOP

GROUPBOX "내부 단어 자동 완성:",IDC_STATIC,7,111,218,26
AUTOCHECKBOX "주석",IDC_AUTO_COMPLETE_INSIDE_COMMONT,14,123,65,10,WS_TABSTOP
Expand Down
4 changes: 2 additions & 2 deletions locale/pt-BR/Notepad4.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1620,8 +1620,8 @@ BEGIN
EDITTEXT IDC_AUTOC_MIN_NUMBER_LENGTH,166,48,50,12,ES_NUMBER | WS_TABSTOP
AUTOCHECKBOX "Scanning words in current document for",IDC_AUTOC_SCAN_DOCUMENT_WORDS,14,68,150,10,WS_TABSTOP
EDITTEXT IDC_AUTOC_SCAN_WORDS_TIMEOUT,166,64,50,12,WS_TABSTOP
AUTOCHECKBOX "Only trigger auto completion in English IME mode.",IDC_AUTOC_ENGLISH_IME_ONLY,14,80,180,10,WS_TABSTOP
AUTOCHECKBOX "Auto completion is case insensitive.",IDC_AUTOC_CASE_INSENSITIVE,14,92,180,10,WS_TABSTOP
AUTOCHECKBOX "Only use words in current document.",IDC_AUTOC_ONLY_DOCUMENT_WORDS,14,80,180,10,WS_TABSTOP
AUTOCHECKBOX "Only trigger auto completion in English IME mode.",IDC_AUTOC_ENGLISH_IME_ONLY,14,92,180,10,WS_TABSTOP

GROUPBOX "Auto complete word inside:",IDC_STATIC,7,111,218,26
AUTOCHECKBOX "Comment",IDC_AUTO_COMPLETE_INSIDE_COMMONT,14,123,65,10,WS_TABSTOP
Expand Down
4 changes: 2 additions & 2 deletions locale/zh-Hans/Notepad4.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1620,8 +1620,8 @@ BEGIN
EDITTEXT IDC_AUTOC_MIN_NUMBER_LENGTH,166,48,50,12,ES_NUMBER | WS_TABSTOP
AUTOCHECKBOX "在以下时间内扫描当前文档中的单词",IDC_AUTOC_SCAN_DOCUMENT_WORDS,14,68,150,10,WS_TABSTOP
EDITTEXT IDC_AUTOC_SCAN_WORDS_TIMEOUT,166,64,50,12,WS_TABSTOP
AUTOCHECKBOX "仅在英文输入法模式下触发自动完成",IDC_AUTOC_ENGLISH_IME_ONLY,14,80,180,10,WS_TABSTOP
AUTOCHECKBOX "自动完成忽略大小写",IDC_AUTOC_CASE_INSENSITIVE,14,92,180,10,WS_TABSTOP
AUTOCHECKBOX "仅使用当前文档中的单词",IDC_AUTOC_ONLY_DOCUMENT_WORDS,14,80,180,10,WS_TABSTOP
AUTOCHECKBOX "仅在英文输入法模式下触发自动完成",IDC_AUTOC_ENGLISH_IME_ONLY,14,92,180,10,WS_TABSTOP

GROUPBOX "在以下内容中启用单词自动完成:",IDC_STATIC,7,111,218,26
AUTOCHECKBOX "注释",IDC_AUTO_COMPLETE_INSIDE_COMMONT,14,123,65,10,WS_TABSTOP
Expand Down
4 changes: 2 additions & 2 deletions locale/zh-Hant/Notepad4.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1620,8 +1620,8 @@ BEGIN
EDITTEXT IDC_AUTOC_MIN_NUMBER_LENGTH,166,48,50,12,ES_NUMBER | WS_TABSTOP
AUTOCHECKBOX "在以下時間內掃描目前文中的單詞",IDC_AUTOC_SCAN_DOCUMENT_WORDS,14,68,150,10,WS_TABSTOP
EDITTEXT IDC_AUTOC_SCAN_WORDS_TIMEOUT,166,64,50,12,WS_TABSTOP
AUTOCHECKBOX "只在英文輸入法模式下觸發自動完成",IDC_AUTOC_ENGLISH_IME_ONLY,14,80,180,10,WS_TABSTOP
AUTOCHECKBOX "自動完成忽略大小寫",IDC_AUTOC_CASE_INSENSITIVE,14,92,180,10,WS_TABSTOP
AUTOCHECKBOX "僅使用當前文檔中的單詞",IDC_AUTOC_ONLY_DOCUMENT_WORDS,14,80,180,10,WS_TABSTOP
AUTOCHECKBOX "只在英文輸入法模式下觸發自動完成",IDC_AUTOC_ENGLISH_IME_ONLY,14,92,180,10,WS_TABSTOP

GROUPBOX "在以下內容中啟用單詞自動完成:",IDC_STATIC,7,111,218,26
AUTOCHECKBOX "注释",IDC_AUTO_COMPLETE_INSIDE_COMMONT,14,123,65,10,WS_TABSTOP
Expand Down
12 changes: 6 additions & 6 deletions src/Dialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2284,11 +2284,11 @@ static INT_PTR CALLBACK AutoCompletionSettingsDlgProc(HWND hwnd, UINT umsg, WPAR
if (autoCompletionConfig.bScanWordsInDocument) {
CheckDlgButton(hwnd, IDC_AUTOC_SCAN_DOCUMENT_WORDS, BST_CHECKED);
}
if (autoCompletionConfig.bEnglistIMEModeOnly) {
CheckDlgButton(hwnd, IDC_AUTOC_ENGLISH_IME_ONLY, BST_CHECKED);
if (autoCompletionConfig.bOnlyWordsInDocument) {
CheckDlgButton(hwnd, IDC_AUTOC_ONLY_DOCUMENT_WORDS, BST_CHECKED);
}
if (autoCompletionConfig.bIgnoreCase) {
CheckDlgButton(hwnd, IDC_AUTOC_CASE_INSENSITIVE, BST_CHECKED);
if (autoCompletionConfig.bEnglishIMEModeOnly) {
CheckDlgButton(hwnd, IDC_AUTOC_ENGLISH_IME_ONLY, BST_CHECKED);
}

SetDlgItemInt(hwnd, IDC_AUTOC_VISIBLE_ITEM_COUNT, autoCompletionConfig.iVisibleItemCount, FALSE);
Expand Down Expand Up @@ -2386,8 +2386,8 @@ static INT_PTR CALLBACK AutoCompletionSettingsDlgProc(HWND hwnd, UINT umsg, WPAR

autoCompletionConfig.bCompleteWord = IsButtonChecked(hwnd, IDC_AUTO_COMPLETE_WORD);
autoCompletionConfig.bScanWordsInDocument = IsButtonChecked(hwnd, IDC_AUTOC_SCAN_DOCUMENT_WORDS);
autoCompletionConfig.bEnglistIMEModeOnly = IsButtonChecked(hwnd, IDC_AUTOC_ENGLISH_IME_ONLY);
autoCompletionConfig.bIgnoreCase = IsButtonChecked(hwnd, IDC_AUTOC_CASE_INSENSITIVE);
autoCompletionConfig.bOnlyWordsInDocument = IsButtonChecked(hwnd, IDC_AUTOC_ONLY_DOCUMENT_WORDS);
autoCompletionConfig.bEnglishIMEModeOnly = IsButtonChecked(hwnd, IDC_AUTOC_ENGLISH_IME_ONLY);

int mask = GetDlgItemInt(hwnd, IDC_AUTOC_VISIBLE_ITEM_COUNT, nullptr, FALSE);
autoCompletionConfig.iVisibleItemCount = max(mask, MIN_AUTO_COMPLETION_VISIBLE_ITEM_COUNT);
Expand Down
3 changes: 2 additions & 1 deletion src/Edit.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ struct EditAutoCompletionConfig {
int fCompleteScope;
int fScanWordScope;
UINT dwScanWordsTimeout;
bool bEnglistIMEModeOnly;
bool bOnlyWordsInDocument;
bool bEnglishIMEModeOnly;
bool bIgnoreCase;
bool bLaTeXInputMethod;
UINT iVisibleItemCount;
Expand Down
2 changes: 1 addition & 1 deletion src/EditAutoC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,7 @@ static bool EditCompleteWordCore(int iCondition, bool autoInsert) noexcept {
watch.Start();
#endif

bool bIgnoreLexer = (pRoot[0] >= '0' && pRoot[0] <= '9'); // number
bool bIgnoreLexer = autoCompletionConfig.bOnlyWordsInDocument || (pRoot[0] >= '0' && pRoot[0] <= '9'); // number
const bool bIgnoreCase = bIgnoreLexer || autoCompletionConfig.bIgnoreCase;
WordList pWList;
pWList.Init(pRoot, iRootLen, bIgnoreCase);
Expand Down
8 changes: 5 additions & 3 deletions src/Notepad4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4993,7 +4993,7 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) {
// auto complete word
if (!autoCompletionConfig.bCompleteWord
// ignore IME input
|| (scn->characterSource != SC_CHARACTERSOURCE_DIRECT_INPUT && (ch >= 0x80 || autoCompletionConfig.bEnglistIMEModeOnly))
|| (scn->characterSource != SC_CHARACTERSOURCE_DIRECT_INPUT && (ch >= 0x80 || autoCompletionConfig.bEnglishIMEModeOnly))
|| !IsAutoCompletionWordCharacter(ch)
) {
return 0;
Expand Down Expand Up @@ -5424,7 +5424,8 @@ void LoadSettings() noexcept {
autoCompletionConfig.fScanWordScope = iValue >> 4;
iValue = section.GetInt(L"AutoCScanWordsTimeout", AUTOC_SCAN_WORDS_DEFAULT_TIMEOUT);
autoCompletionConfig.dwScanWordsTimeout = max(iValue, AUTOC_SCAN_WORDS_MIN_TIMEOUT);
autoCompletionConfig.bEnglistIMEModeOnly = section.GetBool(L"AutoCEnglishIMEModeOnly", false);
autoCompletionConfig.bOnlyWordsInDocument = section.GetBool(L"AutoCOnlyWordsInDocument", false);
autoCompletionConfig.bEnglishIMEModeOnly = section.GetBool(L"AutoCEnglishIMEModeOnly", false);
autoCompletionConfig.bIgnoreCase = section.GetBool(L"AutoCIgnoreCase", false);
autoCompletionConfig.bLaTeXInputMethod = section.GetBool(L"LaTeXInputMethod", false);
iValue = section.GetInt(L"AutoCVisibleItemCount", 16);
Expand Down Expand Up @@ -5773,7 +5774,8 @@ void SaveSettings(bool bSaveSettingsNow) noexcept {
iValue = autoCompletionConfig.fCompleteScope | (autoCompletionConfig.fScanWordScope << 4);
section.SetIntEx(L"AutoCompleteScope", iValue, AutoCompleteScope_Default);
section.SetIntEx(L"AutoCScanWordsTimeout", autoCompletionConfig.dwScanWordsTimeout, AUTOC_SCAN_WORDS_DEFAULT_TIMEOUT);
section.SetBoolEx(L"AutoCEnglishIMEModeOnly", autoCompletionConfig.bEnglistIMEModeOnly, false);
section.SetBoolEx(L"AutoCOnlyWordsInDocument", autoCompletionConfig.bOnlyWordsInDocument, false);
section.SetBoolEx(L"AutoCEnglishIMEModeOnly", autoCompletionConfig.bEnglishIMEModeOnly, false);
section.SetBoolEx(L"AutoCIgnoreCase", autoCompletionConfig.bIgnoreCase, false);
section.SetBoolEx(L"LaTeXInputMethod", autoCompletionConfig.bLaTeXInputMethod, false);
section.SetIntEx(L"AutoCVisibleItemCount", autoCompletionConfig.iVisibleItemCount, 16);
Expand Down
4 changes: 2 additions & 2 deletions src/Notepad4.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1620,8 +1620,8 @@ BEGIN
EDITTEXT IDC_AUTOC_MIN_NUMBER_LENGTH,166,48,50,12,ES_NUMBER | WS_TABSTOP
AUTOCHECKBOX "Scanning words in current document for",IDC_AUTOC_SCAN_DOCUMENT_WORDS,14,68,150,10,WS_TABSTOP
EDITTEXT IDC_AUTOC_SCAN_WORDS_TIMEOUT,166,64,50,12,WS_TABSTOP
AUTOCHECKBOX "Only trigger auto completion in English IME mode.",IDC_AUTOC_ENGLISH_IME_ONLY,14,80,180,10,WS_TABSTOP
AUTOCHECKBOX "Auto completion is case insensitive.",IDC_AUTOC_CASE_INSENSITIVE,14,92,180,10,WS_TABSTOP
AUTOCHECKBOX "Only use words in current document.",IDC_AUTOC_ONLY_DOCUMENT_WORDS,14,80,180,10,WS_TABSTOP
AUTOCHECKBOX "Only trigger auto completion in English IME mode.",IDC_AUTOC_ENGLISH_IME_ONLY,14,92,180,10,WS_TABSTOP

GROUPBOX "Auto complete word inside:",IDC_STATIC,7,111,218,26
AUTOCHECKBOX "Comment",IDC_AUTO_COMPLETE_INSIDE_COMMONT,14,123,65,10,WS_TABSTOP
Expand Down
4 changes: 2 additions & 2 deletions src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@
#define IDC_AUTOC_MIN_WORD_LENGTH 152
#define IDC_AUTOC_MIN_NUMBER_LENGTH 153
#define IDC_AUTOC_SCAN_DOCUMENT_WORDS 154
#define IDC_AUTOC_ENGLISH_IME_ONLY 155
#define IDC_AUTOC_CASE_INSENSITIVE 156
#define IDC_AUTOC_ONLY_DOCUMENT_WORDS 155
#define IDC_AUTOC_ENGLISH_IME_ONLY 156
#define IDC_AUTOC_SCAN_WORDS_TIMEOUT 157
#define IDC_AUTO_COMPLETE_INSIDE_COMMONT 180
#define IDC_AUTO_COMPLETE_INSIDE_STRING 181
Expand Down
2 changes: 1 addition & 1 deletion wiki
Submodule wiki updated from 8a4446 to a8acee

0 comments on commit 352a188

Please sign in to comment.