diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml
index aa4ef2ea6..084bee069 100644
--- a/PowerEditor/installer/nativeLang/english.xml
+++ b/PowerEditor/installer/nativeLang/english.xml
@@ -1095,11 +1095,20 @@ Translation note:
+
+
+
+
+
+
+
+
+
@@ -1107,8 +1116,7 @@ Translation note:
-
-
+
@@ -1793,6 +1801,11 @@ Click on "?" button on right to open website with User Manual."/>
+
+
diff --git a/PowerEditor/installer/nativeLang/english_customizable.xml b/PowerEditor/installer/nativeLang/english_customizable.xml
index 731ecfcbd..088404308 100644
--- a/PowerEditor/installer/nativeLang/english_customizable.xml
+++ b/PowerEditor/installer/nativeLang/english_customizable.xml
@@ -1100,6 +1100,14 @@ Translation note:
+
+
+
+
+
+
+
+
@@ -1107,8 +1115,7 @@ Translation note:
-
-
+
@@ -1793,6 +1800,11 @@ Click on "?" button on right to open website with User Manual."/>
+
+
diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml
index 63ae41319..19772a204 100644
--- a/PowerEditor/installer/nativeLang/french.xml
+++ b/PowerEditor/installer/nativeLang/french.xml
@@ -1101,14 +1101,21 @@ Translation note:
-
+
+
+
+
+
+
+
+
+
-
-
+
@@ -1796,6 +1803,11 @@ Cliquez sur le bouton « ? » à droite pour ouvrir le site web du manuel utilis
+
+
diff --git a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml
index 0e081d3d0..c0450575d 100644
--- a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml
+++ b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml
@@ -1050,18 +1050,29 @@
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1624,6 +1635,11 @@
2. 如果「停用自動換行」被啟動,在開啟一個大型文件時,「自動換行」將對所有文件停用。 你可以通過選單「檢視->自動換行」重新啟動這個功能。"/>
+
+
diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp
index c2f3c9744..0c662d93a 100644
--- a/PowerEditor/src/Notepad_plus.cpp
+++ b/PowerEditor/src/Notepad_plus.cpp
@@ -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 ||
diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp
index 165fe8cf0..2af2736f3 100644
--- a/PowerEditor/src/NppNotification.cpp
+++ b/PowerEditor/src/NppNotification.cpp
@@ -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(notification->ch));
Buffer* currentBuf = _pEditView->getCurrentBuffer();
diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp
index 8912993ea..e73920c56 100644
--- a/PowerEditor/src/Parameters.cpp
+++ b/PowerEditor/src/Parameters.cpp
@@ -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()
// yes
{
- 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));
}
// yes< / GUIConfig>
diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h
index 8a3ab7917..b94f3f0f1 100644
--- a/PowerEditor/src/Parameters.h
+++ b/PowerEditor/src/Parameters.h
@@ -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;
diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc
index eb13e77cf..c759c30b1 100644
--- a/PowerEditor/src/WinControls/Preference/preference.rc
+++ b/PowerEditor/src/WinControls/Preference/preference.rc
@@ -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
diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp
index dd658d34f..1429157f2 100644
--- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp
+++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp
@@ -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(i) != L_USER)
- {
- int cmdID = nppParam.langTypeToCommandID(static_cast(i));
- if ((cmdID != -1))
- {
- getNameStrFromCmd(cmdID, str);
- if (str.length() > 0)
- {
- _langList.push_back(LangMenuItem(static_cast(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(_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(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(tipAutoIndentBasic2Show.c_str()), pNativeSpeaker->isRTL());
+ _tipAutoIndentAdvanced = CreateToolTip(IDC_RADIO_AUTOINDENT_ADVANCED, _hSelf, _hInst, const_cast(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(-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(i) != L_USER)
+ {
+ int cmdID = nppParam.langTypeToCommandID(static_cast(i));
+ if ((cmdID != -1))
+ {
+ getNameStrFromCmd(cmdID, str);
+ if (str.length() > 0)
+ {
+ _langList.push_back(LangMenuItem(static_cast(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(_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(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(wParam));
+ }
+
+ case WM_CTLCOLORLISTBOX:
+ {
+ return NppDarkMode::onCtlColorListbox(wParam, lParam);
+ }
+
+ case WM_CTLCOLORDLG:
+ case WM_CTLCOLORSTATIC:
+ {
+ return NppDarkMode::onCtlColorDarker(reinterpret_cast(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(-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);
diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.h b/PowerEditor/src/WinControls/Preference/preferenceDlg.h
index 152ec2cdf..38e5d03ad 100644
--- a/PowerEditor/src/WinControls/Preference/preferenceDlg.h
+++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.h
@@ -184,11 +184,35 @@ public :
LanguageSubDlg() = default;
private :
- LexerStylerArray _lsArray;
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
std::vector _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;
diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h
index 564ea8e68..920e278bd 100644
--- a/PowerEditor/src/WinControls/Preference/preference_rc.h
+++ b/PowerEditor/src/WinControls/Preference/preference_rc.h
@@ -14,8 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-#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)
diff --git a/PowerEditor/src/localization.cpp b/PowerEditor/src/localization.cpp
index 89b9457fb..66d6c3fd6 100644
--- a/PowerEditor/src/localization.cpp
+++ b/PowerEditor/src/localization.cpp
@@ -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')
{