-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add helper dialog to convert newlines in the multiline edit dialog to…
… regex newlines closes #522
- Loading branch information
1 parent
cb5e0ac
commit cff8ba6
Showing
9 changed files
with
382 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
// grepWin - regex search and replace for Windows | ||
|
||
// Copyright (C) 2024 - Stefan Kueng | ||
|
||
// This program is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU General Public License | ||
// as published by the Free Software Foundation; either version 2 | ||
// of the License, or (at your option) any later version. | ||
|
||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with this program; if not, write to the Free Software Foundation, | ||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
// | ||
#include "stdafx.h" | ||
#include "resource.h" | ||
#include "NewlinesDlg.h" | ||
#include "Theme.h" | ||
#include <boost/regex.hpp> | ||
|
||
CNewlinesDlg::CNewlinesDlg(HWND hParent) | ||
: m_hParent(hParent) | ||
, m_themeCallbackId(0) | ||
, m_newLines(eNewlines::None) | ||
{ | ||
} | ||
|
||
CNewlinesDlg::~CNewlinesDlg() | ||
{ | ||
} | ||
void CNewlinesDlg::setNewLines(eNewlines nl) | ||
{ | ||
m_newLines = nl; | ||
} | ||
eNewlines CNewlinesDlg::getNewLines() const | ||
{ | ||
return m_newLines; | ||
} | ||
void CNewlinesDlg::setShowBoth(bool show) | ||
{ | ||
m_showBoth = show; | ||
} | ||
|
||
LRESULT CNewlinesDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) | ||
{ | ||
UNREFERENCED_PARAMETER(lParam); | ||
switch (uMsg) | ||
{ | ||
case WM_INITDIALOG: | ||
{ | ||
m_themeCallbackId = CTheme::Instance().RegisterThemeChangeCallback( | ||
[this]() { | ||
CTheme::Instance().SetThemeForDialog(*this, CTheme::Instance().IsDarkTheme()); | ||
}); | ||
CTheme::Instance().SetThemeForDialog(*this, CTheme::Instance().IsDarkTheme()); | ||
|
||
InitDialog(hwndDlg, IDI_GREPWIN); | ||
CLanguage::Instance().TranslateWindow(*this); | ||
// initialize the controls | ||
switch (m_newLines) | ||
{ | ||
case eNewlines::None: | ||
CheckRadioButton(hwndDlg, IDC_CRLF, IDC_BOTH, IDC_CRLF); | ||
|
||
break; | ||
case eNewlines::Linux: | ||
CheckRadioButton(hwndDlg, IDC_CRLF, IDC_BOTH, IDC_LF); | ||
break; | ||
case eNewlines::Windows: | ||
CheckRadioButton(hwndDlg, IDC_CRLF, IDC_BOTH, IDC_CRLF); | ||
break; | ||
case eNewlines::Both: | ||
CheckRadioButton(hwndDlg, IDC_CRLF, IDC_BOTH, IDC_BOTH); | ||
break; | ||
} | ||
if (!m_showBoth) | ||
{ | ||
ShowWindow(GetDlgItem(hwndDlg, IDC_BOTH), SW_HIDE); | ||
} | ||
} | ||
return FALSE; | ||
case WM_COMMAND: | ||
return DoCommand(LOWORD(wParam), HIWORD(wParam)); | ||
case WM_CLOSE: | ||
CTheme::Instance().RemoveRegisteredCallback(m_themeCallbackId); | ||
break; | ||
default: | ||
return FALSE; | ||
} | ||
return FALSE; | ||
} | ||
|
||
LRESULT CNewlinesDlg::DoCommand(int id, int /*msg*/) | ||
{ | ||
switch (id) | ||
{ | ||
case IDOK: | ||
if (IsDlgButtonChecked(*this, IDC_LF) == BST_CHECKED) | ||
{ | ||
m_newLines = eNewlines::Linux; | ||
} | ||
else if (IsDlgButtonChecked(*this, IDC_CRLF) == BST_CHECKED) | ||
{ | ||
m_newLines = eNewlines::Windows; | ||
} | ||
else if (IsDlgButtonChecked(*this, IDC_BOTH) == BST_CHECKED) | ||
{ | ||
m_newLines = eNewlines::Both; | ||
} | ||
[[fallthrough]]; | ||
case IDCANCEL: | ||
EndDialog(*this, id); | ||
break; | ||
} | ||
return 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// grepWin - regex search and replace for Windows | ||
|
||
// Copyright (C) 2024 - Stefan Kueng | ||
|
||
// This program is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU General Public License | ||
// as published by the Free Software Foundation; either version 2 | ||
// of the License, or (at your option) any later version. | ||
|
||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with this program; if not, write to the Free Software Foundation, | ||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
// | ||
#pragma once | ||
#include "BaseDialog.h" | ||
|
||
enum class eNewlines | ||
{ | ||
None, | ||
Linux, | ||
Windows, | ||
Both, | ||
}; | ||
|
||
class CNewlinesDlg : public CDialog | ||
{ | ||
public: | ||
CNewlinesDlg(HWND hParent); | ||
~CNewlinesDlg() override; | ||
|
||
void setNewLines(eNewlines nl); | ||
eNewlines getNewLines() const; | ||
void setShowBoth(bool show); | ||
|
||
protected: | ||
LRESULT CALLBACK DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) override; | ||
LRESULT DoCommand(int id, int msg); | ||
|
||
private: | ||
HWND m_hParent; | ||
int m_themeCallbackId; | ||
eNewlines m_newLines; | ||
bool m_showBoth; | ||
}; |
Oops, something went wrong.