mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-27 07:44:24 +02:00
parent
cd6a6ac3bb
commit
50a50cce3c
@ -845,6 +845,12 @@ bool Notepad_plus::saveGUIParams()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Notepad_plus::saveColumnEditorParams()
|
||||
{
|
||||
NppParameters& nppParams = NppParameters::getInstance();
|
||||
return nppParams.writeColumnEditorSettings();
|
||||
}
|
||||
|
||||
bool Notepad_plus::saveProjectPanelsParams()
|
||||
{
|
||||
NppParameters& nppParams = NppParameters::getInstance();
|
||||
|
@ -195,6 +195,7 @@ public:
|
||||
bool saveGUIParams();
|
||||
bool saveProjectPanelsParams();
|
||||
bool saveFileBrowserParam();
|
||||
bool saveColumnEditorParams();
|
||||
void saveDockingParams();
|
||||
void saveUserDefineLangs();
|
||||
void saveShortcuts();
|
||||
|
@ -2139,6 +2139,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
|
||||
if (!saveProjectPanelsParams()) allClosed = false; //writeProjectPanelsSettings
|
||||
saveFileBrowserParam();
|
||||
saveColumnEditorParams();
|
||||
|
||||
if (!allClosed)
|
||||
{
|
||||
|
@ -1744,6 +1744,9 @@ bool NppParameters::getUserParametersFromXmlTree()
|
||||
//Get File browser parameters
|
||||
feedFileBrowserParameters(root);
|
||||
|
||||
//Get Column editor parameters
|
||||
feedColumnEditorParameters(root);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2344,6 +2347,63 @@ void NppParameters::feedProjectPanelsParameters(TiXmlNode *node)
|
||||
}
|
||||
}
|
||||
|
||||
void NppParameters::feedColumnEditorParameters(TiXmlNode *node)
|
||||
{
|
||||
TiXmlNode * columnEditorRoot = node->FirstChildElement(TEXT("ColumnEditor"));
|
||||
if (!columnEditorRoot) return;
|
||||
|
||||
const TCHAR* strVal = (columnEditorRoot->ToElement())->Attribute(TEXT("choice"));
|
||||
if (strVal)
|
||||
{
|
||||
if (lstrcmp(strVal, TEXT("text")) == 0)
|
||||
_columnEditParam._mainChoice = false;
|
||||
else
|
||||
_columnEditParam._mainChoice = true;
|
||||
}
|
||||
TiXmlNode *childNode = columnEditorRoot->FirstChildElement(TEXT("text"));
|
||||
if (!childNode) return;
|
||||
|
||||
const TCHAR* content = (childNode->ToElement())->Attribute(TEXT("content"));
|
||||
if (content)
|
||||
{
|
||||
_columnEditParam._insertedTextContent = content;
|
||||
}
|
||||
|
||||
childNode = columnEditorRoot->FirstChildElement(TEXT("number"));
|
||||
if (!childNode) return;
|
||||
|
||||
int val;
|
||||
strVal = (childNode->ToElement())->Attribute(TEXT("initial"), &val);
|
||||
if (strVal)
|
||||
_columnEditParam._initialNum = val;
|
||||
|
||||
strVal = (childNode->ToElement())->Attribute(TEXT("increase"), &val);
|
||||
if (strVal)
|
||||
_columnEditParam._increaseNum = val;
|
||||
|
||||
strVal = (childNode->ToElement())->Attribute(TEXT("repeat"), &val);
|
||||
if (strVal)
|
||||
_columnEditParam._repeatNum = val;
|
||||
|
||||
strVal = (childNode->ToElement())->Attribute(TEXT("formatChoice"));
|
||||
|
||||
if (strVal)
|
||||
{
|
||||
if (lstrcmp(strVal, TEXT("hex")) == 0)
|
||||
_columnEditParam._formatChoice = 1;
|
||||
else if (lstrcmp(strVal, TEXT("oct")) == 0)
|
||||
_columnEditParam._formatChoice = 2;
|
||||
else if (lstrcmp(strVal, TEXT("bin")) == 0)
|
||||
_columnEditParam._formatChoice = 3;
|
||||
else // "bin"
|
||||
_columnEditParam._formatChoice = 0;
|
||||
}
|
||||
|
||||
const TCHAR* boolStr = (childNode->ToElement())->Attribute(TEXT("leadingZeros"));
|
||||
if (boolStr)
|
||||
_columnEditParam._isLeadingZeros = (lstrcmp(TEXT("yes"), boolStr) == 0);
|
||||
}
|
||||
|
||||
void NppParameters::feedFindHistoryParameters(TiXmlNode *node)
|
||||
{
|
||||
TiXmlNode *findHistoryRoot = node->FirstChildElement(TEXT("FindHistory"));
|
||||
@ -3789,6 +3849,54 @@ bool NppParameters::writeRecentFileHistorySettings(int nbMaxFile) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NppParameters::writeColumnEditorSettings() const
|
||||
{
|
||||
if (!_pXmlUserDoc) return false;
|
||||
|
||||
TiXmlNode *nppRoot = _pXmlUserDoc->FirstChild(TEXT("NotepadPlus"));
|
||||
if (!nppRoot)
|
||||
{
|
||||
nppRoot = _pXmlUserDoc->InsertEndChild(TiXmlElement(TEXT("NotepadPlus")));
|
||||
}
|
||||
|
||||
TiXmlNode *oldColumnEditorNode = nppRoot->FirstChildElement(TEXT("ColumnEditor"));
|
||||
if (oldColumnEditorNode)
|
||||
{
|
||||
// Erase the Project Panel root
|
||||
nppRoot->RemoveChild(oldColumnEditorNode);
|
||||
}
|
||||
|
||||
// Create the new ColumnEditor root
|
||||
TiXmlElement columnEditorRootNode{TEXT("ColumnEditor")};
|
||||
(columnEditorRootNode.ToElement())->SetAttribute(TEXT("choice"), _columnEditParam._mainChoice ? L"number" : L"text");
|
||||
|
||||
TiXmlElement textNode{ TEXT("text") };
|
||||
(textNode.ToElement())->SetAttribute(TEXT("content"), _columnEditParam._insertedTextContent.c_str());
|
||||
(columnEditorRootNode.ToElement())->InsertEndChild(textNode);
|
||||
|
||||
TiXmlElement numberNode{ TEXT("number") };
|
||||
(numberNode.ToElement())->SetAttribute(TEXT("initial"), _columnEditParam._initialNum);
|
||||
(numberNode.ToElement())->SetAttribute(TEXT("increase"), _columnEditParam._increaseNum);
|
||||
(numberNode.ToElement())->SetAttribute(TEXT("repeat"), _columnEditParam._repeatNum);
|
||||
(numberNode.ToElement())->SetAttribute(TEXT("leadingZeros"), _columnEditParam._isLeadingZeros ? L"yes" : L"no");
|
||||
|
||||
wstring format = TEXT("dec");
|
||||
if (_columnEditParam._formatChoice == 1)
|
||||
format = TEXT("hex");
|
||||
else if (_columnEditParam._formatChoice == 2)
|
||||
format = TEXT("oct");
|
||||
else if (_columnEditParam._formatChoice == 3)
|
||||
format = TEXT("bin");
|
||||
(numberNode.ToElement())->SetAttribute(TEXT("formatChoice"), format);
|
||||
(columnEditorRootNode.ToElement())->InsertEndChild(numberNode);
|
||||
|
||||
|
||||
|
||||
// (Re)Insert the Project Panel root
|
||||
(nppRoot->ToElement())->InsertEndChild(columnEditorRootNode);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NppParameters::writeProjectPanelsSettings() const
|
||||
{
|
||||
if (!_pXmlUserDoc) return false;
|
||||
|
@ -1188,7 +1188,18 @@ struct FindHistory final
|
||||
bool _regexBackward4PowerUser = false;
|
||||
};
|
||||
|
||||
struct ColumnEditorParam final
|
||||
{
|
||||
bool _mainChoice = true; // true (1): text false (0): number
|
||||
|
||||
std::wstring _insertedTextContent;
|
||||
|
||||
int _initialNum = -1;
|
||||
int _increaseNum = -1;
|
||||
int _repeatNum = -1;
|
||||
bool _isLeadingZeros = false;
|
||||
int _formatChoice = 0; // 0:Dec 1:Hex 2:Oct 3:Bin
|
||||
};
|
||||
|
||||
class LocalizationSwitcher final
|
||||
{
|
||||
@ -1429,6 +1440,7 @@ public:
|
||||
bool writeHistory(const TCHAR *fullpath);
|
||||
|
||||
bool writeProjectPanelsSettings() const;
|
||||
bool writeColumnEditorSettings() const;
|
||||
bool writeFileBrowserSettings(const std::vector<generic_string> & rootPath, const generic_string & latestSelectedItemPath) const;
|
||||
|
||||
TiXmlNode* getChildElementByAttribut(TiXmlNode *pere, const TCHAR *childName, const TCHAR *attributName, const TCHAR *attributVal) const;
|
||||
@ -1696,13 +1708,11 @@ public:
|
||||
_cmdSettingsDir = settingsDir;
|
||||
};
|
||||
|
||||
void setTitleBarAdd(const generic_string& titleAdd)
|
||||
{
|
||||
void setTitleBarAdd(const generic_string& titleAdd) {
|
||||
_titleBarAdditional = titleAdd;
|
||||
}
|
||||
|
||||
const generic_string& getTitleBarAdd() const
|
||||
{
|
||||
const generic_string& getTitleBarAdd() const {
|
||||
return _titleBarAdditional;
|
||||
}
|
||||
|
||||
@ -1715,6 +1725,8 @@ public:
|
||||
void removeIndexFromXmlUdls(size_t i);
|
||||
bool isStylerDocLoaded() const { return _pXmlUserStylerDoc != nullptr; };
|
||||
|
||||
ColumnEditorParam _columnEditParam;
|
||||
|
||||
private:
|
||||
NppParameters();
|
||||
~NppParameters();
|
||||
@ -1903,6 +1915,7 @@ private:
|
||||
void feedFindHistoryParameters(TiXmlNode *node);
|
||||
void feedProjectPanelsParameters(TiXmlNode *node);
|
||||
void feedFileBrowserParameters(TiXmlNode *node);
|
||||
void feedColumnEditorParameters(TiXmlNode *node);
|
||||
bool feedStylerArray(TiXmlNode *node);
|
||||
std::pair<unsigned char, unsigned char> feedUserLang(TiXmlNode *node);
|
||||
void feedUserStyles(TiXmlNode *node);
|
||||
|
@ -42,10 +42,31 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
|
||||
{
|
||||
case WM_INITDIALOG :
|
||||
{
|
||||
ColumnEditorParam colEditParam = NppParameters::getInstance()._columnEditParam;
|
||||
NppDarkMode::autoSubclassAndThemeChildControls(_hSelf);
|
||||
|
||||
switchTo(activeText);
|
||||
::SendDlgItemMessage(_hSelf, IDC_COL_DEC_RADIO, BM_SETCHECK, TRUE, 0);
|
||||
::SetDlgItemText(_hSelf, IDC_COL_TEXT_EDIT, colEditParam._insertedTextContent.c_str());
|
||||
|
||||
if (colEditParam._initialNum != -1)
|
||||
::SetDlgItemInt(_hSelf, IDC_COL_INITNUM_EDIT, colEditParam._initialNum, FALSE);
|
||||
if (colEditParam._increaseNum != -1)
|
||||
::SetDlgItemInt(_hSelf, IDC_COL_INCREASENUM_EDIT, colEditParam._increaseNum, FALSE);
|
||||
if (colEditParam._repeatNum != -1)
|
||||
::SetDlgItemInt(_hSelf, IDC_COL_REPEATNUM_EDIT, colEditParam._repeatNum, FALSE);
|
||||
|
||||
::SendDlgItemMessage(_hSelf, IDC_COL_LEADZERO_CHECK, BM_SETCHECK, colEditParam._isLeadingZeros, 0);
|
||||
|
||||
int format = IDC_COL_DEC_RADIO;
|
||||
if (colEditParam._formatChoice == 1)
|
||||
format = IDC_COL_HEX_RADIO;
|
||||
else if (colEditParam._formatChoice == 2)
|
||||
format = IDC_COL_OCT_RADIO;
|
||||
else if (colEditParam._formatChoice == 3)
|
||||
format = IDC_COL_BIN_RADIO;
|
||||
|
||||
::SendDlgItemMessage(_hSelf, format, BM_SETCHECK, TRUE, 0);
|
||||
|
||||
switchTo(colEditParam._mainChoice);
|
||||
goToCenter();
|
||||
|
||||
return TRUE;
|
||||
@ -320,7 +341,34 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
|
||||
case IDC_COL_TEXT_RADIO :
|
||||
case IDC_COL_NUM_RADIO :
|
||||
{
|
||||
switchTo((wParam == IDC_COL_TEXT_RADIO)? activeText : activeNumeric);
|
||||
ColumnEditorParam& colEditParam = NppParameters::getInstance()._columnEditParam;
|
||||
colEditParam._mainChoice = (wParam == IDC_COL_TEXT_RADIO) ? activeText : activeNumeric;
|
||||
switchTo(colEditParam._mainChoice);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case IDC_COL_DEC_RADIO:
|
||||
case IDC_COL_OCT_RADIO:
|
||||
case IDC_COL_HEX_RADIO:
|
||||
case IDC_COL_BIN_RADIO:
|
||||
{
|
||||
ColumnEditorParam& colEditParam = NppParameters::getInstance()._columnEditParam;
|
||||
colEditParam._formatChoice = 0; // dec
|
||||
if (wParam == IDC_COL_HEX_RADIO)
|
||||
colEditParam._formatChoice = 1;
|
||||
else if (wParam == IDC_COL_OCT_RADIO)
|
||||
colEditParam._formatChoice = 2;
|
||||
else if (wParam == IDC_COL_BIN_RADIO)
|
||||
colEditParam._formatChoice = 3;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case IDC_COL_LEADZERO_CHECK:
|
||||
{
|
||||
ColumnEditorParam& colEditParam = NppParameters::getInstance()._columnEditParam;
|
||||
bool isLeadingZeros = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_LEADZERO_CHECK, BM_GETCHECK, 0, 0));
|
||||
colEditParam._isLeadingZeros = isLeadingZeros;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -328,17 +376,69 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
|
||||
{
|
||||
switch (HIWORD(wParam))
|
||||
{
|
||||
case EN_SETFOCUS :
|
||||
case BN_SETFOCUS :
|
||||
//updateLinesNumbers();
|
||||
return TRUE;
|
||||
default :
|
||||
case EN_CHANGE:
|
||||
{
|
||||
ColumnEditorParam& colEditParam = NppParameters::getInstance()._columnEditParam;
|
||||
const int stringSize = MAX_PATH;
|
||||
TCHAR str[stringSize];
|
||||
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDC_COL_TEXT_EDIT:
|
||||
{
|
||||
::GetDlgItemText(_hSelf, LOWORD(wParam), str, stringSize);
|
||||
colEditParam._insertedTextContent = str;
|
||||
return TRUE;
|
||||
}
|
||||
case IDC_COL_INITNUM_EDIT:
|
||||
{
|
||||
::GetDlgItemText(_hSelf, LOWORD(wParam), str, stringSize);
|
||||
|
||||
if (lstrcmp(str, TEXT("")) == 0)
|
||||
{
|
||||
colEditParam._initialNum = -1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int num = ::GetDlgItemInt(_hSelf, LOWORD(wParam), NULL, TRUE);
|
||||
colEditParam._initialNum = num;
|
||||
return TRUE;
|
||||
}
|
||||
case IDC_COL_INCREASENUM_EDIT:
|
||||
{
|
||||
::GetDlgItemText(_hSelf, LOWORD(wParam), str, stringSize);
|
||||
|
||||
if (lstrcmp(str, TEXT("")) == 0)
|
||||
{
|
||||
colEditParam._increaseNum = -1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int num = ::GetDlgItemInt(_hSelf, LOWORD(wParam), NULL, TRUE);
|
||||
colEditParam._increaseNum = num;
|
||||
return TRUE;
|
||||
}
|
||||
case IDC_COL_REPEATNUM_EDIT:
|
||||
{
|
||||
::GetDlgItemText(_hSelf, LOWORD(wParam), str, stringSize);
|
||||
|
||||
if (lstrcmp(str, TEXT("")) == 0)
|
||||
{
|
||||
colEditParam._repeatNum = -1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int num = ::GetDlgItemInt(_hSelf, LOWORD(wParam), NULL, TRUE);
|
||||
colEditParam._repeatNum = num;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
default :
|
||||
return FALSE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user