Make C-Like indent deactivatable

Add one more option for auto-indent so user can choose among "none", "basic" & "advance".
Also add the indentation section in Preferences dialog.

Fix #15396, close #15414
This commit is contained in:
Don Ho 2024-07-09 03:08:12 +02:00
parent 761060819f
commit 439bbb04d2
13 changed files with 554 additions and 304 deletions

View File

@ -1095,11 +1095,20 @@ Translation note:
<Item id="4010" name="Registered extensions:"/>
</FileAssoc>
<Language title="Language">
<Item id="6505" name="Available items"/>
<Item id="6506" name="Disabled items"/>
<Item id="6507" name="Make language menu compact"/>
<Item id="6508" name="Language Menu"/>
<Item id="6335" name="Treat backslash as escape character for SQL"/>
</Language>
<Indentation title="Indentation">
<Item id="7161" name="Auto-indent"/>
<Item id="7162" name="None"/>
<Item id="7163" name="Basic"/>
<Item id="7164" name="Advanced"/>
<Item id="6301" name="Indent Settings"/>
<Item id="6302" name="Space character(s)"/>
<Item id="6303" name="Indent size:"/>
@ -1107,8 +1116,7 @@ Translation note:
<Item id="6311" name="Tab character"/>
<Item id="6510" name="Use default value"/>
<Item id="6512" name="Backspace key unindents instead of removing single space"/>
<Item id="6335" name="Treat backslash as escape character for SQL"/>
</Language>
</Indentation>
<Highlighting title="Highlighting">
<Item id="6351" name="Style All Occurrences of Token"/>
@ -1793,6 +1801,11 @@ Click on &quot;?&quot; button on right to open website with User Manual."/>
<npcIncludeCcUniEol-tip value="Apply non-printing characters appearance settings to C0, C1 control and Unicode EOL (next line, line separator and paragraph separator) characters."/>
<searchingInSelThresh-tip value="Number of selected characters in edit zone to automatically check the &quot;In selection&quot; checkbox when the Find dialog is activated. The maximum value is 1024. Set the value to 0 to disable auto-checking."/>
<verticalEdge-tip value="Add your column marker by indicating its position with a decimal number. You can define several column markers by using white space to separate the different numbers."/>
<autoIndentBasic-tip value="Ensure that the indentation of the current line (i.e. the new line created by pressing the ENTER key) matches the indentation of the previous line."/>
<autoIndentAdvanced-tip value="Enable smart indentation for 'C-like' languages and Python. The 'C-like' languages include:
C, C++, Java, C#, Objective-C, PHP, JavaScript, JSP, CSS, Perl, Rust, PowerShell and JSON
If you select advanced mode but do not edit files in the aforementioned languages, the indentation will remain in basic mode."/>
</MiscStrings>
</Native-Langue>
</NotepadPlus>

View File

@ -1100,6 +1100,14 @@ Translation note:
<Item id="6506" name="Disabled items"/>
<Item id="6507" name="Make language menu compact"/>
<Item id="6508" name="Language Menu"/>
<Item id="6335" name="Treat backslash as escape character for SQL"/>
</Language>
<Indentation title="Indentation">
<Item id="7161" name="Auto-indent"/>
<Item id="7162" name="None"/>
<Item id="7163" name="Basic"/>
<Item id="7164" name="Advanced"/>
<Item id="6301" name="Indent Settings"/>
<Item id="6302" name="Space character(s)"/>
<Item id="6303" name="Indent size:"/>
@ -1107,8 +1115,7 @@ Translation note:
<Item id="6311" name="Tab character"/>
<Item id="6510" name="Use default value"/>
<Item id="6512" name="Backspace key unindents instead of removing single space"/>
<Item id="6335" name="Treat backslash as escape character for SQL"/>
</Language>
</Indentation>
<Highlighting title="Highlighting">
<Item id="6351" name="Style All Occurrences of Token"/>
@ -1793,6 +1800,11 @@ Click on &quot;?&quot; button on right to open website with User Manual."/>
<npcIncludeCcUniEol-tip value="Apply non-printing characters appearance settings to C0, C1 control and Unicode EOL (next line, line separator and paragraph separator) characters."/>
<searchingInSelThresh-tip value="Number of selected characters in edit zone to automatically check the &quot;In selection&quot; checkbox when the Find dialog is activated. The maximum value is 1024. Set the value to 0 to disable auto-checking."/>
<verticalEdge-tip value="Add your column marker by indicating its position with a decimal number. You can define several column markers by using white space to separate the different numbers."/>
<autoIndentBasic-tip value="Ensure that the indentation of the current line (i.e. the new line created by pressing the ENTER key) matches the indentation of the previous line."/>
<autoIndentAdvanced-tip value="Enable smart indentation for 'C-like' languages and Python. The 'C-like' languages include:
C, C++, Java, C#, Objective-C, PHP, JavaScript, JSP, CSS, Perl, Rust, PowerShell and JSON
If you select advanced mode but do not edit files in the aforementioned languages, the indentation will remain in basic mode."/>
</MiscStrings>
</Native-Langue>
</NotepadPlus>

View File

@ -1101,14 +1101,21 @@ Translation note:
<Item id="6506" name="Langages cachés"/>
<Item id="6507" name="Compacter le « Menu langage »"/>
<Item id="6508" name="Menu langage"/>
<Item id="6301" name="Tabulations"/>
<Item id="6335" name="Barre oblique inversée : caractère d'échappement pour SQL"/>
</Language>
<Indentation title="Indentation">
<Item id="7161" name="Indentation automatique"/>
<Item id="7162" name="Désactivé"/>
<Item id="7163" name="Basique"/>
<Item id="7164" name="Avancé"/>
<Item id="6301" name="Indentation"/>
<Item id="6302" name="Insertion despaces"/>
<Item id="6303" name="Taille de l'indentation :"/>
<Item id="6310" name="Indenter par :"/>
<Item id="6311" name="Caractère de tabulation"/>
<Item id="6510" name="Utiliser la valeur par défaut"/>
<Item id="6335" name="Barre oblique inversée : caractère d'échappement pour SQL"/>
</Language>
</Indentation>
<Highlighting title="Coloration">
<Item id="6351" name="Marquer tout"/>
@ -1796,6 +1803,11 @@ Cliquez sur le bouton « ? » à droite pour ouvrir le site web du manuel utilis
<npcIncludeCcUniEol-tip value="Applique les paramètres dapparence des caractères non-imprimables aux contrôles C0, C1 et aux caractères Unicode EOL (ligne suivante, séparateur de ligne et séparateur de paragraphe)."/>
<searchingInSelThresh-tip value="Nombre de caractères sélectionnés dans la zone dédition pour cocher automatiquement la case « Dans sélection » quand la fenêtre de recherche est activée. La valeur maximale est 1024. Mettre la valeur à 0 pour désactiver lauto-coche."/>
<verticalEdge-tip value="Ajoutez votre marqueur de colonne en indiquant sa position avec un nombre entier. Vous pouvez définir plusieurs marqueurs de colonne en utilisant un espace pour séparer les différents nombres."/>
<autoIndentBasic-tip value="Assurez-vous que la ligne courante (c'est-à-dire la nouvelle ligne saisie en appuyant sur ENTRÉE) a la même indentation que la ligne précédente."/>
<autoIndentAdvanced-tip value="Activer l'indentation intelligente pour les langages de « type C » et Python. Les langages de « type C » comprennent :
C, C++, Java, C#, Objective-C, PHP, JavaScript, JSP, CSS, Perl, Rust, PowerShell et JSON
Si vous sélectionnez le mode avancé sans modifier les fichiers des langues mentionnées ci-dessus, les paramètres d'indentation resteront en mode basique."/>
</MiscStrings>
</Native-Langue>
</NotepadPlus>

View File

@ -1050,18 +1050,29 @@
<Item id="4009" name="支援的副檔名"/>
<Item id="4010" name="已連結的副檔名"/>
</FileAssoc>
<Language title="程式語言">
<Item id="6505" name="可用項目"/>
<Item id="6506" name="停用項目"/>
<Item id="6507" name="簡化程式語言選單"/>
<Item id="6508" name="程式語言選單"/>
<Item id="6301" name="縮排設定"/>
<Item id="6302" name="使用空格"/>
<Item id="6303" name="縮排大小:"/>
<Item id="6510" name="使用預設值"/>
<Item id="6335" name="在 SQL 中視「\」為逸出字元"/>
</Language>
<Indentation title="縮排">
<Item id="7161" name="自動縮排"/>
<Item id="7162" name="關閉"/>
<Item id="7163" name="基本模式"/>
<Item id="7164" name="進階模式"/>
<Item id="6301" name="縮排設定"/>
<Item id="6302" name="空格"/>
<Item id="6303" name="縮排大小:"/>
<Item id="6310" name="縮排使用:"/>
<Item id="6311" name="Tab 字元"/>
<Item id="6510" name="使用預設值"/>
<Item id="6512" name="退格鍵取消縮排而不是刪除單一空格"/>
</Indentation>
<Highlighting title="醒目提示">
<Item id="6351" name="全部標記"/>
<Item id="6352" name="區分大小寫"/>
@ -1624,6 +1635,11 @@
2. 如果「停用自動換行」被啟動,在開啟一個大型文件時,「自動換行」將對所有文件停用。 你可以通過選單「檢視-&gt;自動換行」重新啟動這個功能。"/>
<searchingInSelThresh-tip value="在尋找與取代對話方塊啟動時,為啟動自動勾選核取方塊「僅尋找選取範圍」在編輯區中選取的字符數量。 最大值為 1024。 將值設置為 0 將停止自動勾選功能。"/>
<verticalEdge-tip value="如欲添加列標記可以在下面以數字指示其列位置。使用空格分隔不同數字來定義多個列標記。"/>
<autoIndentBasic-tip value="確保目前行(即按 ENTER 鍵所打的新行)的縮排與上一行的縮排相同。"/>
<autoIndentAdvanced-tip value="啟用為「類 C Python C
C、C++、Java、C#、Objective-C、PHP、JavaScript、JSP、CSS、Perl、Rust、PowerShell 與 JSON
如果你選擇進階模式但不編輯上述語言文件,縮排設定將保留為基本模式。"/>
</MiscStrings>
</Native-Langue>
</NotepadPlus>

View File

@ -3557,12 +3557,21 @@ intptr_t Notepad_plus::findMachedBracePos(size_t startPos, size_t endPos, char t
void Notepad_plus::maintainIndentation(wchar_t ch)
{
const NppGUI& nppGui = NppParameters::getInstance().getNppGUI();
if (nppGui._maintainIndent == autoIndent_none)
return;
intptr_t eolMode = _pEditView->execute(SCI_GETEOLMODE);
intptr_t curLine = _pEditView->getCurrentLineNumber();
intptr_t prevLine = curLine - 1;
intptr_t indentAmountPrevLine = 0;
intptr_t tabWidth = _pEditView->execute(SCI_GETTABWIDTH);
// Do not alter indentation if we were at the beginning of the line and we pressed Enter
if ((((eolMode == SC_EOL_CRLF || eolMode == SC_EOL_LF) && ch == '\n') ||
(eolMode == SC_EOL_CR && ch == '\r')) && prevLine >= 0 && _pEditView->getLineLength(prevLine) == 0)
return;
LangType type = _pEditView->getCurrentBuffer()->getLangType();
ExternalLexerAutoIndentMode autoIndentMode = ExternalLexerAutoIndentMode::Standard;
@ -3575,10 +3584,30 @@ void Notepad_plus::maintainIndentation(wchar_t ch)
return;
}
// Do not alter indentation if we were at the beginning of the line and we pressed Enter
if ((((eolMode == SC_EOL_CRLF || eolMode == SC_EOL_LF) && ch == '\n') ||
(eolMode == SC_EOL_CR && ch == '\r')) && prevLine >= 0 && _pEditView->getLineLength(prevLine) == 0)
if (nppGui._maintainIndent == autoIndent_basic) // Basic indentation mode only
{
if (((eolMode == SC_EOL_CRLF || eolMode == SC_EOL_LF) && ch == '\n') ||
(eolMode == SC_EOL_CR && ch == '\r'))
{
// Search the non-empty previous line
while (prevLine >= 0 && _pEditView->getLineLength(prevLine) == 0)
prevLine--;
if (prevLine >= 0)
{
indentAmountPrevLine = _pEditView->getLineIndent(prevLine);
}
if (indentAmountPrevLine > 0)
{
_pEditView->setLineIndent(curLine, indentAmountPrevLine);
}
}
return;
}
// else nppGui._maintainIndent == autoIndent_advance
if (type == L_C || type == L_CPP || type == L_JAVA || type == L_CS || type == L_OBJC ||
type == L_PHP || type == L_JS || type == L_JAVASCRIPT || type == L_JSP || type == L_CSS || type == L_PERL ||

View File

@ -692,8 +692,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
if (!_recordingMacro && !_playingBackMacro) // No macro recording or playing back
{
const NppGUI & nppGui = NppParameters::getInstance().getNppGUI();
bool indentMaintain = nppGui._maintainIndent;
if (indentMaintain)
if (nppGui._maintainIndent != autoIndent_none)
maintainIndentation(static_cast<wchar_t>(notification->ch));
Buffer* currentBuf = _pEditView->getCurrentBuffer();

View File

@ -5079,10 +5079,21 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
const wchar_t* val = n->Value();
if (val)
{
// the retro-compatibility with the old values
if (lstrcmp(val, L"yes") == 0)
_nppGUI._maintainIndent = true;
else
_nppGUI._maintainIndent = false;
_nppGUI._maintainIndent = autoIndent_advanced;
else if (lstrcmp(val, L"no") == 0)
_nppGUI._maintainIndent = autoIndent_none;
// the treatment of the new values
else if (lstrcmp(val, L"0") == 0)
_nppGUI._maintainIndent = autoIndent_none;
else if (lstrcmp(val, L"1") == 0)
_nppGUI._maintainIndent = autoIndent_advanced;
else if (lstrcmp(val, L"2") == 0)
_nppGUI._maintainIndent = autoIndent_basic;
else // other values will be ignored - use the default value
_nppGUI._maintainIndent = autoIndent_advanced;
}
}
}
@ -7365,7 +7376,12 @@ void NppParameters::createXmlTreeFromGUIParams()
// <GUIConfig name="MaintainIndent">yes</GUIConfig>
{
insertGUIConfigBoolNode(newGUIRoot, L"MaintainIndent", _nppGUI._maintainIndent);
//insertGUIConfigBoolNode(newGUIRoot, L"MaintainIndent", _nppGUI._maintainIndent);
wchar_t szStr[12] = L"0";
_itow(_nppGUI._maintainIndent, szStr, 10);
TiXmlElement* GUIConfigElement = (newGUIRoot->InsertEndChild(TiXmlElement(L"GUIConfig")))->ToElement();
GUIConfigElement->SetAttribute(L"name", L"MaintainIndent");
GUIConfigElement->InsertEndChild(TiXmlText(szStr));
}
// <GUIConfig name = "TagsMatchHighLight" TagAttrHighLight = "yes" HighLightNonHtmlZone = "no">yes< / GUIConfig>

View File

@ -118,6 +118,8 @@ enum urlMode {urlDisable = 0, urlNoUnderLineFg, urlUnderLineFg, urlNoUnderLineBg
urlMin = urlDisable,
urlMax = urlUnderLineBg};
enum AutoIndentMode { autoIndent_none = 0, autoIndent_advanced = 1, autoIndent_basic = 2 };
const int LANG_INDEX_INSTR = 0;
const int LANG_INDEX_INSTR2 = 1;
const int LANG_INDEX_TYPE = 2;
@ -817,7 +819,7 @@ struct NppGUI final
bool _saveAllConfirm = true;
bool _setSaveDlgExtFiltToAllTypes = false;
bool _doTaskList = true;
bool _maintainIndent = true;
AutoIndentMode _maintainIndent = autoIndent_advanced;
bool _enableSmartHilite = true;
bool _smartHiliteCaseSensitive = false;

View File

@ -272,28 +272,37 @@ IDD_PREFERENCE_SUB_LANGUAGE DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
GROUPBOX "Language Menu",IDC_CHECK_LANGMENU_GR_STATIC,11,0,220,181,BS_CENTER
CONTROL "Make language menu compact",IDC_CHECK_LANGMENUCOMPACT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,14,174,10
CTEXT "Available items",IDC_ENABLEDITEMS_STATIC,29,31,72,8
LISTBOX IDC_LIST_ENABLEDLANG,24,44,78,120,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "->",IDC_BUTTON_REMOVE,109,76,25,14
PUSHBUTTON "<-",IDC_BUTTON_RESTORE,109,107,25,14
CTEXT "Disabled items",IDC_DISABLEDITEMS_STATIC,144,31,72,8
LISTBOX IDC_LIST_DISABLEDLANG,141,44,78,120,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
CONTROL "Treat backslash as escape character for SQL",IDC_CHECK_BACKSLASHISESCAPECHARACTERFORSQL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,184,217,10
GROUPBOX "Indent Settings",IDC_TABSETTING_GB_STATIC,242,0,211,195,BS_CENTER
LISTBOX IDC_LIST_TABSETTNG,307,15,84,70,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
GROUPBOX "",IDC_GR_TABVALUE_STATIC,254,92,188,92,BS_CENTER
CONTROL "Use default value",IDC_CHECK_DEFAULTTABVALUE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,250,91,122,10
RTEXT "Indent size:",IDC_TABSIZE_STATIC,262,105,98,8
EDITTEXT IDC_EDIT_TABSIZEVAL,362,103,14,12,ES_CENTER | ES_NUMBER
LTEXT "Indent using:",IDC_INDENTUSING_STATIC,259,118,135,8
CONTROL "Tab character",IDC_RADIO_USINGTAB,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,264,130,165,10
CONTROL "Space character(s)",IDC_RADIO_REPLACEBYSPACE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,264,143,165,10
CONTROL "Backspace key unindents instead of removing single space",IDC_CHECK_BACKSPACEUNINDENT,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,258,158,180,21
GROUPBOX "Language Menu",IDC_CHECK_LANGMENU_GR_STATIC,120,0,220,181,BS_CENTER
CONTROL "Make language menu compact",IDC_CHECK_LANGMENUCOMPACT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,134,14,174,10
CTEXT "Available items",IDC_ENABLEDITEMS_STATIC,138,31,72,8
LISTBOX IDC_LIST_ENABLEDLANG,133,44,78,120,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "->",IDC_BUTTON_REMOVE,218,76,25,14
PUSHBUTTON "<-",IDC_BUTTON_RESTORE,218,107,25,14
CTEXT "Disabled items",IDC_DISABLEDITEMS_STATIC,253,31,72,8
LISTBOX IDC_LIST_DISABLEDLANG,250,44,78,120,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
CONTROL "Treat backslash as escape character for SQL",IDC_CHECK_BACKSLASHISESCAPECHARACTERFORSQL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,123,184,217,10
END
IDD_PREFERENCE_SUB_INDENTATION DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
GROUPBOX "Indent Settings",IDC_TABSETTING_GB_STATIC,62,0,212,194,BS_CENTER
LISTBOX IDC_LIST_TABSETTNG,127,15,84,70,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
GROUPBOX "",IDC_GR_TABVALUE_STATIC,72,92,192,92,BS_CENTER
CONTROL "Use default value",IDC_CHECK_DEFAULTTABVALUE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,68,91,122,10
RTEXT "Indent size:",IDC_TABSIZE_STATIC,82,105,98,8
EDITTEXT IDC_EDIT_TABSIZEVAL,182,103,14,12,ES_CENTER | ES_NUMBER
LTEXT "Indent using:",IDC_INDENTUSING_STATIC,78,118,135,8
CONTROL "Tab character",IDC_RADIO_USINGTAB,"Button",BS_AUTORADIOBUTTON | WS_GROUP,84,131,165,10
CONTROL "Space character(s)",IDC_RADIO_REPLACEBYSPACE,"Button",BS_AUTORADIOBUTTON,84,144,165,10
CONTROL "Backspace key unindents instead of removing single space",IDC_CHECK_BACKSPACEUNINDENT,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | BS_TOP | WS_TABSTOP,78,159,180,20
GROUPBOX "Auto-indent",IDC_GROUPSTATIC_AUTOINDENT,284,0,112,59,BS_CENTER
CONTROL "None",IDC_RADIO_AUTOINDENT_NONE,"Button",BS_AUTORADIOBUTTON | WS_GROUP,290,13,100,10
CONTROL "Basic",IDC_RADIO_AUTOINDENT_BASIC,"Button",BS_AUTORADIOBUTTON,290,28,100,10
CONTROL "Advanced",IDC_RADIO_AUTOINDENT_ADVANCED,"Button",BS_AUTORADIOBUTTON,290,43,100,10
END
IDD_PREFERENCE_SUB_HIGHLIGHTING DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
@ -424,46 +433,42 @@ IDD_PREFERENCE_SUB_AUTOCOMPLETION DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
GROUPBOX "Auto-Completion",IDD_AUTOC_GRPSTATIC,33,3,289,105,BS_CENTER
CONTROL "Enable auto-completion on each input",IDD_AUTOC_ENABLECHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,39,16,160,10
CONTROL "Function completion",IDD_AUTOC_FUNCRADIO,"Button",BS_AUTORADIOBUTTON | WS_GROUP,51,31,145,10
CONTROL "Word completion",IDD_AUTOC_WORDRADIO,"Button",BS_AUTORADIOBUTTON,51,46,145,10
CONTROL "Function and word completion",IDD_AUTOC_BOTHRADIO,"Button",BS_AUTORADIOBUTTON,51,61,145,10
CONTROL "Make auto-completion list brief",IDD_AUTOC_BRIEF_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,39,76,160,10
CONTROL "Function parameters hint on input",IDD_FUNC_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,39,93,160,10
GROUPBOX "Auto-Completion",IDD_AUTOC_GRPSTATIC,81,3,289,105,BS_CENTER
CONTROL "Enable auto-completion on each input",IDD_AUTOC_ENABLECHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,87,16,160,10
CONTROL "Function completion",IDD_AUTOC_FUNCRADIO,"Button",BS_AUTORADIOBUTTON | WS_GROUP,99,31,145,10
CONTROL "Word completion",IDD_AUTOC_WORDRADIO,"Button",BS_AUTORADIOBUTTON,99,46,145,10
CONTROL "Function and word completion",IDD_AUTOC_BOTHRADIO,"Button",BS_AUTORADIOBUTTON,99,61,145,10
CONTROL "Make auto-completion list brief",IDD_AUTOC_BRIEF_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,87,76,160,10
CONTROL "Function parameters hint on input",IDD_FUNC_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,87,93,160,10
RTEXT "From",IDD_AUTOC_STATIC_FROM,243,16,47,8
CTEXT "1",IDD_AUTOC_STATIC_N,294,16,8,8
LTEXT "th character",IDD_AUTOC_STATIC_CHAR,308,16,57,8
CONTROL "",IDC_AUTOC_CHAR_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | TBS_TRANSPARENTBKGND | WS_TABSTOP,281,29,66,13
RTEXT "1",IDD_AUTOC_SLIDER_MIN_STATIC,271,30,8,8
LTEXT "9",IDD_AUTOC_SLIDER_MAX_STATIC,349,30,8,8
GROUPBOX "Insert Selection",IDD_AUTOC_USEKEY_GRP_STATIC,266,44,96,43,BS_CENTER
CONTROL "TAB",IDD_AUTOC_USETAB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,272,57,54,10
CONTROL "ENTER",IDD_AUTOC_USEENTER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,272,72,55,10
CONTROL "Ignore numbers",IDD_AUTOC_IGNORENUMBERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,266,93,96,10
RTEXT "From",IDD_AUTOC_STATIC_FROM,195,16,47,8
CTEXT "1",IDD_AUTOC_STATIC_N,246,16,8,8
LTEXT "th character",IDD_AUTOC_STATIC_CHAR,260,16,57,8
CONTROL "",IDC_AUTOC_CHAR_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | TBS_TRANSPARENTBKGND | WS_TABSTOP,233,29,66,13
RTEXT "1",IDD_AUTOC_SLIDER_MIN_STATIC,223,30,8,8
LTEXT "9",IDD_AUTOC_SLIDER_MAX_STATIC,301,30,8,8
GROUPBOX "Insert Selection",IDD_AUTOC_USEKEY_GRP_STATIC,218,44,96,43,BS_CENTER
CONTROL "TAB",IDD_AUTOC_USETAB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,224,57,54,10
CONTROL "ENTER",IDD_AUTOC_USEENTER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,224,72,55,10
CONTROL "Ignore numbers",IDD_AUTOC_IGNORENUMBERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,218,93,96,10
CONTROL "Auto-indent",IDC_CHECK_MAINTAININDENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,347,16,100,10
GROUPBOX "Auto-Insert",IDD_AUTOCINSERT_GRPSTATIC,33,114,289,83,BS_CENTER
CONTROL " (",IDD_AUTOCPARENTHESES_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,50,140,24,10
CONTROL " [",IDD_AUTOCBRACKET_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,50,160,24,10
CONTROL " {",IDD_AUTOCCURLYBRACKET_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,50,180,24,10
CONTROL " """,IDD_AUTOC_DOUBLEQUOTESCHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,94,140,24,10
CONTROL " '",IDD_AUTOC_QUOTESCHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,94,160,24,10
CONTROL " html/xml close tag",IDD_AUTOCTAG_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,94,180,96,10
RTEXT "Open",IDC_MACHEDPAIROPEN_STATIC,254,126,25,8
LTEXT "Close",IDC_MACHEDPAIRCLOSE_STATIC,292,126,25,8
RTEXT "Matched pair 1:",IDC_MACHEDPAIR_STATIC1,190,140,70,8
EDITTEXT IDC_MACHEDPAIROPEN_EDIT1,264,138,14,12,ES_CENTER
EDITTEXT IDC_MACHEDPAIRCLOSE_EDIT1,292,138,14,12,ES_CENTER
RTEXT "Matched pair 2:",IDC_MACHEDPAIR_STATIC2,190,160,70,8
EDITTEXT IDC_MACHEDPAIROPEN_EDIT2,264,158,14,12,ES_CENTER
EDITTEXT IDC_MACHEDPAIRCLOSE_EDIT2,292,158,14,12,ES_CENTER
RTEXT "Matched pair 3:",IDC_MACHEDPAIR_STATIC3,190,180,70,8
EDITTEXT IDC_MACHEDPAIROPEN_EDIT3,264,178,14,12,ES_CENTER
EDITTEXT IDC_MACHEDPAIRCLOSE_EDIT3,292,178,14,12,ES_CENTER
GROUPBOX "Auto-Insert",IDD_AUTOCINSERT_GRPSTATIC,81,114,289,83,BS_CENTER
CONTROL " (",IDD_AUTOCPARENTHESES_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,98,140,24,10
CONTROL " [",IDD_AUTOCBRACKET_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,98,160,24,10
CONTROL " {",IDD_AUTOCCURLYBRACKET_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,98,180,24,10
CONTROL " """,IDD_AUTOC_DOUBLEQUOTESCHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,142,140,24,10
CONTROL " '",IDD_AUTOC_QUOTESCHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,142,160,24,10
CONTROL " html/xml close tag",IDD_AUTOCTAG_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,142,180,96,10
RTEXT "Open",IDC_MACHEDPAIROPEN_STATIC,302,126,25,8
LTEXT "Close",IDC_MACHEDPAIRCLOSE_STATIC,340,126,25,8
RTEXT "Matched pair 1:",IDC_MACHEDPAIR_STATIC1,238,140,70,8
EDITTEXT IDC_MACHEDPAIROPEN_EDIT1,312,138,14,12,ES_CENTER
EDITTEXT IDC_MACHEDPAIRCLOSE_EDIT1,340,138,14,12,ES_CENTER
RTEXT "Matched pair 2:",IDC_MACHEDPAIR_STATIC2,238,160,70,8
EDITTEXT IDC_MACHEDPAIROPEN_EDIT2,312,158,14,12,ES_CENTER
EDITTEXT IDC_MACHEDPAIRCLOSE_EDIT2,340,158,14,12,ES_CENTER
RTEXT "Matched pair 3:",IDC_MACHEDPAIR_STATIC3,238,180,70,8
EDITTEXT IDC_MACHEDPAIROPEN_EDIT3,312,178,14,12,ES_CENTER
EDITTEXT IDC_MACHEDPAIRCLOSE_EDIT3,340,178,14,12,ES_CENTER
END

View File

@ -160,6 +160,9 @@ intptr_t CALLBACK PreferenceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
_languageSubDlg.init(_hInst, _hSelf);
_languageSubDlg.create(IDD_PREFERENCE_SUB_LANGUAGE, false, false);
_indentationSubDlg.init(_hInst, _hSelf);
_indentationSubDlg.create(IDD_PREFERENCE_SUB_INDENTATION, false, false);
_highlightingSubDlg.init(_hInst, _hSelf);
_highlightingSubDlg.create(IDD_PREFERENCE_SUB_HIGHLIGHTING, false, false);
@ -194,6 +197,7 @@ intptr_t CALLBACK PreferenceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
_wVector.push_back(DlgInfo(&_recentFilesHistorySubDlg, L"Recent Files History", L"RecentFilesHistory"));
_wVector.push_back(DlgInfo(&_fileAssocDlg, L"File Association", L"FileAssoc"));
_wVector.push_back(DlgInfo(&_languageSubDlg, L"Language", L"Language"));
_wVector.push_back(DlgInfo(&_indentationSubDlg, L"Indentation", L"Indentation"));
_wVector.push_back(DlgInfo(&_highlightingSubDlg, L"Highlighting", L"Highlighting"));
_wVector.push_back(DlgInfo(&_printSubDlg, L"Print", L"Print"));
_wVector.push_back(DlgInfo(&_searchingSubDlg, L"Searching", L"Searching"));
@ -258,6 +262,11 @@ intptr_t CALLBACK PreferenceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
if (_searchingSubDlg._tipInSelThresh != nullptr)
NppDarkMode::setDarkTooltips(_searchingSubDlg._tipInSelThresh, NppDarkMode::ToolTipsType::tooltip);
if (_indentationSubDlg._tipAutoIndentBasic)
NppDarkMode::setDarkTooltips(_indentationSubDlg._tipAutoIndentBasic, NppDarkMode::ToolTipsType::tooltip);
if (_indentationSubDlg._tipAutoIndentAdvanced)
NppDarkMode::setDarkTooltips(_indentationSubDlg._tipAutoIndentAdvanced, NppDarkMode::ToolTipsType::tooltip);
// groupbox label in dark mode support disabled text color
if (NppDarkMode::isEnabled())
{
@ -377,6 +386,7 @@ intptr_t CALLBACK PreferenceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
_miscSubDlg.dpiManager().setDpiWP(wParam);
_fileAssocDlg.dpiManager().setDpiWP(wParam);
_languageSubDlg.dpiManager().setDpiWP(wParam);
_indentationSubDlg.dpiManager().setDpiWP(wParam);
_highlightingSubDlg.dpiManager().setDpiWP(wParam);
_printSubDlg.dpiManager().setDpiWP(wParam);
_searchingSubDlg.dpiManager().setDpiWP(wParam);
@ -528,6 +538,7 @@ void PreferenceDlg::destroy()
_miscSubDlg.destroy();
_fileAssocDlg.destroy();
_languageSubDlg.destroy();
_indentationSubDlg.destroy();
_highlightingSubDlg.destroy();
_printSubDlg.destroy();
_searchingSubDlg.destroy();
@ -3223,55 +3234,15 @@ intptr_t CALLBACK RecentFilesHistorySubDlg::run_dlgProc(UINT message, WPARAM wPa
return FALSE;
}
intptr_t CALLBACK LanguageSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
intptr_t CALLBACK IndentationSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
NppParameters& nppParam = NppParameters::getInstance();
NppGUI & nppGUI = nppParam.getNppGUI();
NativeLangSpeaker *pNativeSpeaker = nppParam.getNativeLangSpeaker();
switch (message)
{
case WM_INITDIALOG :
{
//
// Lang Menu
//
for (int i = L_TEXT ; i < nppParam.L_END ; ++i)
{
wstring str;
if (static_cast<LangType>(i) != L_USER)
{
int cmdID = nppParam.langTypeToCommandID(static_cast<LangType>(i));
if ((cmdID != -1))
{
getNameStrFromCmd(cmdID, str);
if (str.length() > 0)
{
_langList.push_back(LangMenuItem(static_cast<LangType>(i), cmdID, str));
}
}
}
}
std::sort(_langList.begin(), _langList.end());
for (size_t i = 0, len = _langList.size(); i < len; ++i)
{
::SendDlgItemMessage(_hSelf, IDC_LIST_ENABLEDLANG, LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(_langList[i]._langName.c_str()));
}
std::sort(nppGUI._excludedLangList.begin(), nppGUI._excludedLangList.end());
for (size_t i = 0, len = nppGUI._excludedLangList.size(); i < len ; ++i)
{
::SendDlgItemMessage(_hSelf, IDC_LIST_DISABLEDLANG, LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(nppGUI._excludedLangList[i]._langName.c_str()));
}
::SendDlgItemMessage(_hSelf, IDC_CHECK_LANGMENUCOMPACT, BM_SETCHECK, nppGUI._isLangMenuCompact?BST_CHECKED:BST_UNCHECKED, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_BUTTON_REMOVE), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_BUTTON_RESTORE), FALSE);
//
// Tab settings
//
@ -3293,6 +3264,31 @@ intptr_t CALLBACK LanguageSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
::SendDlgItemMessage(_hSelf, IDC_CHECK_BACKSLASHISESCAPECHARACTERFORSQL, BM_SETCHECK, nppGUI._backSlashIsEscapeCharacterForSql, 0);
//
// Auto-indent settings
//
int choiceID = IDC_RADIO_AUTOINDENT_ADVANCED;
if (nppGUI._maintainIndent == autoIndent_none)
choiceID = IDC_RADIO_AUTOINDENT_NONE;
else if (nppGUI._maintainIndent == autoIndent_basic)
choiceID = IDC_RADIO_AUTOINDENT_BASIC;
::SendDlgItemMessage(_hSelf, choiceID, BM_SETCHECK, TRUE, 0);
NativeLangSpeaker* pNativeSpeaker = nppParam.getNativeLangSpeaker();
wstring tipAutoIndentBasic2Show = pNativeSpeaker->getLocalizedStrFromID("autoIndentBasic-tip",
L"Ensure that the indentation of the current line (i.e. the new line created by pressing the ENTER key) matches the indentation of the previous line.");
wstring tipAutoIndentAdvanced2show = pNativeSpeaker->getLocalizedStrFromID("autoIndentAdvanced-tip",
L"Enable smart indentation for 'C-like' languages and Python. The 'C-like' languages include:\n"\
L"C, C++, Java, C#, Objective-C, PHP, JavaScript, JSP, CSS, Perl, Rust, PowerShell and JSON\n"\
L"\n"\
L"If you select advanced mode but do not edit files in the aforementioned languages, the indentation will remain in basic mode.");
_tipAutoIndentBasic = CreateToolTip(IDC_RADIO_AUTOINDENT_BASIC, _hSelf, _hInst, const_cast<PTSTR>(tipAutoIndentBasic2Show.c_str()), pNativeSpeaker->isRTL());
_tipAutoIndentAdvanced = CreateToolTip(IDC_RADIO_AUTOINDENT_ADVANCED, _hSelf, _hInst, const_cast<PTSTR>(tipAutoIndentAdvanced2show.c_str()), pNativeSpeaker->isRTL());
return TRUE;
}
@ -3345,36 +3341,7 @@ intptr_t CALLBACK LanguageSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
{
case LBN_SELCHANGE:
{
// Lang Menu
if (LOWORD(wParam) == IDC_LIST_DISABLEDLANG || LOWORD(wParam) == IDC_LIST_ENABLEDLANG)
{
int idButton2Enable;
int idButton2Disable;
if (LOWORD(wParam) == IDC_LIST_ENABLEDLANG)
{
idButton2Enable = IDC_BUTTON_REMOVE;
idButton2Disable = IDC_BUTTON_RESTORE;
}
else //IDC_LIST_DISABLEDLANG
{
idButton2Enable = IDC_BUTTON_RESTORE;
idButton2Disable = IDC_BUTTON_REMOVE;
}
auto i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), LB_GETCURSEL, 0, 0);
if (i != LB_ERR)
{
::EnableWindow(::GetDlgItem(_hSelf, idButton2Enable), TRUE);
int idListbox2Disable = (LOWORD(wParam) == IDC_LIST_ENABLEDLANG) ? IDC_LIST_DISABLEDLANG : IDC_LIST_ENABLEDLANG;
::SendDlgItemMessage(_hSelf, idListbox2Disable, LB_SETCURSEL, static_cast<WPARAM>(-1), 0);
::EnableWindow(::GetDlgItem(_hSelf, idButton2Disable), FALSE);
}
return TRUE;
}
// Tab setting
else if (LOWORD(wParam) == IDC_LIST_TABSETTNG)
if (LOWORD(wParam) == IDC_LIST_TABSETTNG)
{
auto index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0);
if (index == LB_ERR)
@ -3427,29 +3394,6 @@ intptr_t CALLBACK LanguageSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
break;
}
// Check if it is double click
case LBN_DBLCLK:
{
// Lang Menu
if (LOWORD(wParam) == IDC_LIST_DISABLEDLANG || LOWORD(wParam) == IDC_LIST_ENABLEDLANG)
{
// On double click an item, the item should be moved
// from one list to other list
HWND(lParam) == ::GetDlgItem(_hSelf, IDC_LIST_ENABLEDLANG) ?
::SendMessage(_hSelf, WM_COMMAND, IDC_BUTTON_REMOVE, 0) :
::SendMessage(_hSelf, WM_COMMAND, IDC_BUTTON_RESTORE, 0);
return TRUE;
}
// Tab setting - Double click is not used at this moment
/*else if (LOWORD(wParam) == IDC_LIST_TABSETTNG)
{
}*/
break;
}
case EN_CHANGE:
{
switch (LOWORD(wParam))
@ -3548,6 +3492,296 @@ intptr_t CALLBACK LanguageSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
}
switch (wParam)
{
case IDC_RADIO_REPLACEBYSPACE:
case IDC_RADIO_USINGTAB:
{
bool isTabReplacedBySpace = BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, IDC_RADIO_REPLACEBYSPACE), BM_GETCHECK, 0, 0);
auto index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0);
if (index == LB_ERR) return FALSE;
if (index != 0)
{
Lang *lang = nppParam.getLangFromIndex(index - 1);
if (!lang) return FALSE;
if (!lang->_tabSize || lang->_tabSize == -1)
lang->_tabSize = nppGUI._tabSize;
if (lang->_langID == L_JS)
{
Lang *ljs = nppParam.getLangFromID(L_JAVASCRIPT);
ljs->_isTabReplacedBySpace = isTabReplacedBySpace;
}
else if (lang->_langID == L_JAVASCRIPT)
{
Lang *ljavascript = nppParam.getLangFromID(L_JS);
ljavascript->_isTabReplacedBySpace = isTabReplacedBySpace;
}
lang->_isTabReplacedBySpace = isTabReplacedBySpace;
// write in langs.xml
nppParam.insertTabInfo(lang->getLangName(), lang->getTabInfo(), lang->_isBackspaceUnindent);
}
else
{
nppGUI._tabReplacedBySpace = isTabReplacedBySpace;
}
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SET_TAB_SETTINGS, 0, 0);
return TRUE;
}
case IDC_CHECK_BACKSPACEUNINDENT:
{
bool isBackspaceUnindent = BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_BACKSPACEUNINDENT), BM_GETCHECK, 0, 0);
auto index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0);
if (index == LB_ERR) return FALSE;
if (index != 0)
{
Lang* lang = nppParam.getLangFromIndex(index - 1);
if (!lang) return FALSE;
if (!lang->_tabSize || lang->_tabSize == -1)
lang->_tabSize = nppGUI._tabSize;
if (lang->_langID == L_JS)
{
Lang* ljs = nppParam.getLangFromID(L_JAVASCRIPT);
ljs->_isBackspaceUnindent = isBackspaceUnindent;
}
else if (lang->_langID == L_JAVASCRIPT)
{
Lang* ljavascript = nppParam.getLangFromID(L_JS);
ljavascript->_isBackspaceUnindent = isBackspaceUnindent;
}
lang->_isBackspaceUnindent = isBackspaceUnindent;
// write in langs.xml
nppParam.insertTabInfo(lang->getLangName(), lang->getTabInfo(), lang->_isBackspaceUnindent);
}
else
{
nppGUI._backspaceUnindent = isBackspaceUnindent;
}
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SET_TAB_SETTINGS, 0, 0);
return TRUE;
}
case IDC_CHECK_DEFAULTTABVALUE:
{
const bool useDefaultTab = isCheckedOrNot(IDC_CHECK_DEFAULTTABVALUE);
const auto index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0);
if (index == LB_ERR || index == 0) // index == 0 shouldn't happen
return FALSE;
Lang *lang = nppParam.getLangFromIndex(index - 1);
if (!lang)
return FALSE;
//- Set tab setting in chosen language
lang->_tabSize = useDefaultTab ? 0 : nppGUI._tabSize;
lang->_isTabReplacedBySpace = useDefaultTab ? false : nppGUI._tabReplacedBySpace;
lang->_isBackspaceUnindent = useDefaultTab ? false : nppGUI._backspaceUnindent;
//- set visual effect
::SetDlgItemInt(_hSelf, IDC_EDIT_TABSIZEVAL, useDefaultTab ? nppGUI._tabSize : lang->_tabSize, FALSE);
setChecked(IDC_RADIO_REPLACEBYSPACE, useDefaultTab ? nppGUI._tabReplacedBySpace : lang->_isTabReplacedBySpace);
setChecked(IDC_RADIO_USINGTAB, useDefaultTab ? !nppGUI._tabReplacedBySpace : !lang->_isTabReplacedBySpace);
setChecked(IDC_CHECK_BACKSPACEUNINDENT, useDefaultTab ? nppGUI._backspaceUnindent : lang->_isBackspaceUnindent);
::EnableWindow(::GetDlgItem(_hSelf, IDC_EDIT_TABSIZEVAL), !useDefaultTab);
::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_REPLACEBYSPACE), !useDefaultTab);
::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_USINGTAB), !useDefaultTab);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_BACKSPACEUNINDENT), !useDefaultTab);
// write in langs.xml
if (useDefaultTab)
nppParam.insertTabInfo(lang->getLangName(), -1, false);
redrawDlgItem(IDC_TABSIZE_STATIC);
redrawDlgItem(IDC_INDENTUSING_STATIC);
return TRUE;
}
case IDC_RADIO_AUTOINDENT_NONE:
{
nppGUI._maintainIndent = autoIndent_none;
return TRUE;
}
case IDC_RADIO_AUTOINDENT_BASIC:
{
nppGUI._maintainIndent = autoIndent_basic;
return TRUE;
}
case IDC_RADIO_AUTOINDENT_ADVANCED:
{
nppGUI._maintainIndent = autoIndent_advanced;
return TRUE;
}
default:
{
break;
}
}
}
[[fallthrough]];
default:
{
break;
}
}
return FALSE;
}
intptr_t CALLBACK LanguageSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
NppParameters& nppParam = NppParameters::getInstance();
NppGUI & nppGUI = nppParam.getNppGUI();
NativeLangSpeaker *pNativeSpeaker = nppParam.getNativeLangSpeaker();
switch (message)
{
case WM_INITDIALOG :
{
//
// Lang Menu
//
for (int i = L_TEXT ; i < nppParam.L_END ; ++i)
{
wstring str;
if (static_cast<LangType>(i) != L_USER)
{
int cmdID = nppParam.langTypeToCommandID(static_cast<LangType>(i));
if ((cmdID != -1))
{
getNameStrFromCmd(cmdID, str);
if (str.length() > 0)
{
_langList.push_back(LangMenuItem(static_cast<LangType>(i), cmdID, str));
}
}
}
}
std::sort(_langList.begin(), _langList.end());
for (size_t i = 0, len = _langList.size(); i < len; ++i)
{
::SendDlgItemMessage(_hSelf, IDC_LIST_ENABLEDLANG, LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(_langList[i]._langName.c_str()));
}
std::sort(nppGUI._excludedLangList.begin(), nppGUI._excludedLangList.end());
for (size_t i = 0, len = nppGUI._excludedLangList.size(); i < len ; ++i)
{
::SendDlgItemMessage(_hSelf, IDC_LIST_DISABLEDLANG, LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(nppGUI._excludedLangList[i]._langName.c_str()));
}
::SendDlgItemMessage(_hSelf, IDC_CHECK_LANGMENUCOMPACT, BM_SETCHECK, nppGUI._isLangMenuCompact?BST_CHECKED:BST_UNCHECKED, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_BUTTON_REMOVE), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_BUTTON_RESTORE), FALSE);
return TRUE;
}
case WM_CTLCOLOREDIT:
{
return NppDarkMode::onCtlColorSofter(reinterpret_cast<HDC>(wParam));
}
case WM_CTLCOLORLISTBOX:
{
return NppDarkMode::onCtlColorListbox(wParam, lParam);
}
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
case WM_PRINTCLIENT:
{
if (NppDarkMode::isEnabled())
{
return TRUE;
}
break;
}
case WM_COMMAND :
{
switch (HIWORD(wParam))
{
case LBN_SELCHANGE:
{
// Lang Menu
if (LOWORD(wParam) == IDC_LIST_DISABLEDLANG || LOWORD(wParam) == IDC_LIST_ENABLEDLANG)
{
int idButton2Enable;
int idButton2Disable;
if (LOWORD(wParam) == IDC_LIST_ENABLEDLANG)
{
idButton2Enable = IDC_BUTTON_REMOVE;
idButton2Disable = IDC_BUTTON_RESTORE;
}
else //IDC_LIST_DISABLEDLANG
{
idButton2Enable = IDC_BUTTON_RESTORE;
idButton2Disable = IDC_BUTTON_REMOVE;
}
auto i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), LB_GETCURSEL, 0, 0);
if (i != LB_ERR)
{
::EnableWindow(::GetDlgItem(_hSelf, idButton2Enable), TRUE);
int idListbox2Disable = (LOWORD(wParam) == IDC_LIST_ENABLEDLANG) ? IDC_LIST_DISABLEDLANG : IDC_LIST_ENABLEDLANG;
::SendDlgItemMessage(_hSelf, idListbox2Disable, LB_SETCURSEL, static_cast<WPARAM>(-1), 0);
::EnableWindow(::GetDlgItem(_hSelf, idButton2Disable), FALSE);
}
return TRUE;
}
break;
}
// Check if it is double click
case LBN_DBLCLK:
{
// Lang Menu
if (LOWORD(wParam) == IDC_LIST_DISABLEDLANG || LOWORD(wParam) == IDC_LIST_ENABLEDLANG)
{
// On double click an item, the item should be moved
// from one list to other list
HWND(lParam) == ::GetDlgItem(_hSelf, IDC_LIST_ENABLEDLANG) ?
::SendMessage(_hSelf, WM_COMMAND, IDC_BUTTON_REMOVE, 0) :
::SendMessage(_hSelf, WM_COMMAND, IDC_BUTTON_RESTORE, 0);
return TRUE;
}
break;
}
default:
{
break;
}
}
switch (wParam)
{
//
@ -3698,123 +3932,6 @@ intptr_t CALLBACK LanguageSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
return TRUE;
}
case IDC_RADIO_REPLACEBYSPACE:
case IDC_RADIO_USINGTAB:
{
bool isTabReplacedBySpace = BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, IDC_RADIO_REPLACEBYSPACE), BM_GETCHECK, 0, 0);
auto index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0);
if (index == LB_ERR) return FALSE;
if (index != 0)
{
Lang *lang = nppParam.getLangFromIndex(index - 1);
if (!lang) return FALSE;
if (!lang->_tabSize || lang->_tabSize == -1)
lang->_tabSize = nppGUI._tabSize;
if (lang->_langID == L_JS)
{
Lang *ljs = nppParam.getLangFromID(L_JAVASCRIPT);
ljs->_isTabReplacedBySpace = isTabReplacedBySpace;
}
else if (lang->_langID == L_JAVASCRIPT)
{
Lang *ljavascript = nppParam.getLangFromID(L_JS);
ljavascript->_isTabReplacedBySpace = isTabReplacedBySpace;
}
lang->_isTabReplacedBySpace = isTabReplacedBySpace;
// write in langs.xml
nppParam.insertTabInfo(lang->getLangName(), lang->getTabInfo(), lang->_isBackspaceUnindent);
}
else
{
nppGUI._tabReplacedBySpace = isTabReplacedBySpace;
}
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SET_TAB_SETTINGS, 0, 0);
return TRUE;
}
case IDC_CHECK_BACKSPACEUNINDENT:
{
bool isBackspaceUnindent = BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_BACKSPACEUNINDENT), BM_GETCHECK, 0, 0);
auto index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0);
if (index == LB_ERR) return FALSE;
if (index != 0)
{
Lang* lang = nppParam.getLangFromIndex(index - 1);
if (!lang) return FALSE;
if (!lang->_tabSize || lang->_tabSize == -1)
lang->_tabSize = nppGUI._tabSize;
if (lang->_langID == L_JS)
{
Lang* ljs = nppParam.getLangFromID(L_JAVASCRIPT);
ljs->_isBackspaceUnindent = isBackspaceUnindent;
}
else if (lang->_langID == L_JAVASCRIPT)
{
Lang* ljavascript = nppParam.getLangFromID(L_JS);
ljavascript->_isBackspaceUnindent = isBackspaceUnindent;
}
lang->_isBackspaceUnindent = isBackspaceUnindent;
// write in langs.xml
nppParam.insertTabInfo(lang->getLangName(), lang->getTabInfo(), lang->_isBackspaceUnindent);
}
else
{
nppGUI._backspaceUnindent = isBackspaceUnindent;
}
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SET_TAB_SETTINGS, 0, 0);
return TRUE;
}
case IDC_CHECK_DEFAULTTABVALUE:
{
const bool useDefaultTab = isCheckedOrNot(IDC_CHECK_DEFAULTTABVALUE);
const auto index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0);
if (index == LB_ERR || index == 0) // index == 0 shouldn't happen
return FALSE;
Lang *lang = nppParam.getLangFromIndex(index - 1);
if (!lang)
return FALSE;
//- Set tab setting in chosen language
lang->_tabSize = useDefaultTab ? 0 : nppGUI._tabSize;
lang->_isTabReplacedBySpace = useDefaultTab ? false : nppGUI._tabReplacedBySpace;
lang->_isBackspaceUnindent = useDefaultTab ? false : nppGUI._backspaceUnindent;
//- set visual effect
::SetDlgItemInt(_hSelf, IDC_EDIT_TABSIZEVAL, useDefaultTab ? nppGUI._tabSize : lang->_tabSize, FALSE);
setChecked(IDC_RADIO_REPLACEBYSPACE, useDefaultTab ? nppGUI._tabReplacedBySpace : lang->_isTabReplacedBySpace);
setChecked(IDC_RADIO_USINGTAB, useDefaultTab ? !nppGUI._tabReplacedBySpace : !lang->_isTabReplacedBySpace);
setChecked(IDC_CHECK_BACKSPACEUNINDENT, useDefaultTab ? nppGUI._backspaceUnindent : lang->_isBackspaceUnindent);
::EnableWindow(::GetDlgItem(_hSelf, IDC_EDIT_TABSIZEVAL), !useDefaultTab);
::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_REPLACEBYSPACE), !useDefaultTab);
::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_USINGTAB), !useDefaultTab);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_BACKSPACEUNINDENT), !useDefaultTab);
// write in langs.xml
if (useDefaultTab)
nppParam.insertTabInfo(lang->getLangName(), -1, false);
redrawDlgItem(IDC_TABSIZE_STATIC);
redrawDlgItem(IDC_INDENTUSING_STATIC);
return TRUE;
}
default:
{
break;
@ -4691,7 +4808,6 @@ intptr_t CALLBACK AutoCompletionSubDlg::run_dlgProc(UINT message, WPARAM wParam,
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_USEKEY_GRP_STATIC), FALSE);
}
}
::SendDlgItemMessage(_hSelf, IDC_CHECK_MAINTAININDENT, BM_SETCHECK, nppGUI._maintainIndent, 0);
::SendDlgItemMessage(_hSelf, IDD_AUTOC_BRIEF_CHECK, BM_SETCHECK, nppGUI._autocBrief ? BST_CHECKED : BST_UNCHECKED, 0);
::SendDlgItemMessage(_hSelf, IDD_FUNC_CHECK, BM_SETCHECK, nppGUI._funcParams ? BST_CHECKED : BST_UNCHECKED, 0);
@ -4848,12 +4964,6 @@ intptr_t CALLBACK AutoCompletionSubDlg::run_dlgProc(UINT message, WPARAM wParam,
switch (wParam)
{
case IDC_CHECK_MAINTAININDENT:
{
nppGUI._maintainIndent = isCheckedOrNot(IDC_CHECK_MAINTAININDENT);
return TRUE;
}
case IDD_AUTOC_ENABLECHECK :
{
bool isEnableAutoC = BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDD_AUTOC_ENABLECHECK, BM_GETCHECK, 0, 0);

View File

@ -184,11 +184,35 @@ public :
LanguageSubDlg() = default;
private :
LexerStylerArray _lsArray;
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
std::vector<LangMenuItem> _langList;
};
class IndentationSubDlg : public StaticDialog
{
friend class PreferenceDlg;
public :
IndentationSubDlg() = default;
~IndentationSubDlg() {
if (_tipAutoIndentBasic != nullptr)
{
::DestroyWindow(_tipAutoIndentBasic);
_tipAutoIndentBasic = nullptr;
}
if (_tipAutoIndentAdvanced != nullptr)
{
::DestroyWindow(_tipAutoIndentAdvanced);
_tipAutoIndentAdvanced = nullptr;
}
};
private :
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
HWND _tipAutoIndentBasic = nullptr;
HWND _tipAutoIndentAdvanced = nullptr;
};
class HighlightingSubDlg : public StaticDialog
{
public :
@ -360,6 +384,7 @@ private :
MiscSubDlg _miscSubDlg;
RegExtDlg _fileAssocDlg;
LanguageSubDlg _languageSubDlg;
IndentationSubDlg _indentationSubDlg;
HighlightingSubDlg _highlightingSubDlg;
PrintSubDlg _printSubDlg;
NewDocumentSubDlg _newDocumentSubDlg;

View File

@ -14,8 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef PREFERENCE_RC_H
#define PREFERENCE_RC_H
#pragma once
//#define PREF_MSG_ISCHECKED_GENERALPAGE (WM_USER + 1) // wParam:checkbox/radiobutton ID in General page. lParam is type of "bool *" to get result
#define PREF_MSG_SETGUITOOLICONSSET (WM_USER + 4) // DM_REPOSITION uses WM_USER + 2
@ -41,7 +40,7 @@
#define IDC_CHECK_ENABLETABCLOSE (IDD_PREFERENCE_SUB_GENRAL + 12)
#define IDC_CHECK_DBCLICK2CLOSE (IDD_PREFERENCE_SUB_GENRAL + 13)
#define IDC_CHECK_ENABLEDOCSWITCHER (IDD_PREFERENCE_SUB_GENRAL + 14)
#define IDC_CHECK_MAINTAININDENT (IDD_PREFERENCE_SUB_GENRAL + 15)
//#define IDC_CHECK_MAINTAININDENT (IDD_PREFERENCE_SUB_GENRAL + 15)
#define IDC_CHECK_KEEPINSAMEDIR (IDD_PREFERENCE_SUB_GENRAL + 16)
#define IDC_CHECK_STYLEMRU (IDD_PREFERENCE_SUB_GENRAL + 17)
#define IDC_CHECK_TAB_HIDE (IDD_PREFERENCE_SUB_GENRAL + 18)
@ -488,7 +487,7 @@
#define IDD_DROPDOWN_RESET_CYAN (IDD_PREFERENCE_SUB_DARKMODE + 40)
#define IDD_DROPDOWN_RESET_OLIVE (IDD_PREFERENCE_SUB_DARKMODE + 41)
#define IDD_PREFERENCE_SUB_PERFORMANCE 7140 //(IDD_PREFERENCE_BOX + 1100)
#define IDD_PREFERENCE_SUB_PERFORMANCE 7140 //(IDD_PREFERENCE_BOX + 1140)
#define IDC_GROUPSTATIC_PERFORMANCE_RESTRICTION (IDD_PREFERENCE_SUB_PERFORMANCE + 1)
#define IDD_PERFORMANCE_TIP_QUESTION_BUTTON (IDD_PREFERENCE_SUB_PERFORMANCE + 2)
#define IDC_CHECK_PERFORMANCE_ENABLE (IDD_PREFERENCE_SUB_PERFORMANCE + 3)
@ -501,4 +500,9 @@
#define IDC_CHECK_PERFORMANCE_DEACTIVATEWORDWRAP (IDD_PREFERENCE_SUB_PERFORMANCE + 10)
#define IDC_CHECK_PERFORMANCE_ALLOWCLICKABLELINK (IDD_PREFERENCE_SUB_PERFORMANCE + 11)
#define IDC_CHECK_PERFORMANCE_SUPPRESS2GBWARNING (IDD_PREFERENCE_SUB_PERFORMANCE + 12)
#endif //PREFERENCE_RC_H
#define IDD_PREFERENCE_SUB_INDENTATION 7160 //(IDD_PREFERENCE_BOX + 1160)
#define IDC_GROUPSTATIC_AUTOINDENT (IDD_PREFERENCE_SUB_INDENTATION + 1)
#define IDC_RADIO_AUTOINDENT_NONE (IDD_PREFERENCE_SUB_INDENTATION + 2)
#define IDC_RADIO_AUTOINDENT_BASIC (IDD_PREFERENCE_SUB_INDENTATION + 3)
#define IDC_RADIO_AUTOINDENT_ADVANCED (IDD_PREFERENCE_SUB_INDENTATION + 4)

View File

@ -1048,6 +1048,13 @@ void NativeLangSpeaker::changePrefereceDlgLang(PreferenceDlg & preference)
preference.renameDialogTitle(L"Language", nameW);
}
changeDlgLang(preference._indentationSubDlg.getHSelf(), "Indentation", titre, titreMaxSize);
if (titre[0] != '\0')
{
const wchar_t *nameW = wmc.char2wchar(titre, _nativeLangEncoding);
preference.renameDialogTitle(L"Indentation", nameW);
}
changeDlgLang(preference._highlightingSubDlg.getHSelf(), "Highlighting", titre, titreMaxSize);
if (titre[0] != '\0')
{