Skip to content

Commit 1da6d55

Browse files
committed
Run clang format on all files
1 parent f8758fa commit 1da6d55

17 files changed

+1123
-1043
lines changed

NppJSONViewer/NppJsonViewer/AboutDlg.cpp

Lines changed: 94 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -7,112 +7,113 @@
77
#include <commctrl.h>
88

99

10-
AboutDlg::AboutDlg(HINSTANCE hIntance, HWND hParent, int nCmdId) : m_nCmdId(nCmdId), StaticDialog()
10+
AboutDlg::AboutDlg(HINSTANCE hIntance, HWND hParent, int nCmdId)
11+
: m_nCmdId(nCmdId)
12+
, StaticDialog()
1113
{
12-
init(hIntance, hParent);
14+
init(hIntance, hParent);
1315
}
1416

1517

1618
bool AboutDlg::ShowDlg(bool bShow)
1719
{
18-
bool bShouldShow = bShow && !isVisible();
19-
if (bShouldShow)
20-
{
21-
if (!isCreated())
22-
create(IDD_ABOUTDLG);
23-
24-
// Adjust the position of AboutBox
25-
goToCenter();
26-
}
27-
else
28-
{
29-
SendMessage(_hSelf, WM_COMMAND, IDCANCEL, NULL);
30-
}
31-
return bShouldShow;
20+
bool bShouldShow = bShow && !isVisible();
21+
if (bShouldShow)
22+
{
23+
if (!isCreated())
24+
create(IDD_ABOUTDLG);
25+
26+
// Adjust the position of AboutBox
27+
goToCenter();
28+
}
29+
else
30+
{
31+
SendMessage(_hSelf, WM_COMMAND, IDCANCEL, NULL);
32+
}
33+
return bShouldShow;
3234
}
3335

3436

3537
INT_PTR AboutDlg::run_dlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
3638
{
37-
AboutDlg* pSelf = nullptr;
38-
switch (uMsg)
39-
{
40-
case WM_INITDIALOG:
41-
{
42-
::SetWindowLongPtr(_hSelf, DWLP_USER, lParam);
43-
44-
pSelf = reinterpret_cast<AboutDlg*>(static_cast<LONG_PTR> (::GetWindowLongPtr(_hSelf, DWLP_USER)));
45-
if (pSelf)
46-
{
47-
pSelf->SetVersion(_hSelf);
48-
}
49-
SetFocus(GetDlgItem(_hSelf, IDOK));
50-
51-
// Set links
52-
std::wstring urlIssue(TEXT("<a href=\"__URL__\">__URL__</a>"));
53-
std::wstring urlRepo = urlIssue;
54-
55-
urlIssue = StringHelper::ReplaceAll(urlIssue, TEXT("__URL__"), URL_REPORT_ISSUE);
56-
urlRepo = StringHelper::ReplaceAll(urlRepo, TEXT("__URL__"), URL_SOURCE_CODE);
57-
58-
SetWindowText(::GetDlgItem(_hSelf, IDC_WEB_ISSUE), urlIssue.c_str());
59-
SetWindowText(::GetDlgItem(_hSelf, IDC_WEB_SOURCE), urlRepo.c_str());
60-
61-
return TRUE;
62-
}
63-
64-
case WM_NOTIFY:
65-
{
66-
switch (reinterpret_cast<LPNMHDR>(lParam)->code)
67-
{
68-
case NM_CLICK:
69-
case NM_RETURN:
70-
{
71-
auto nmLink = reinterpret_cast<PNMLINK>(lParam);
72-
LITEM item = nmLink->item;
73-
74-
ShellExecute(nullptr, L"open", item.szUrl, nullptr, nullptr, SW_SHOW);
75-
return TRUE;
76-
}
77-
}
78-
return FALSE;
79-
}
80-
81-
case WM_COMMAND:
82-
{
83-
pSelf = reinterpret_cast<AboutDlg*>(static_cast<LONG_PTR> (::GetWindowLongPtr(_hSelf, DWLP_USER)));
84-
switch (LOWORD(wParam))
85-
{
86-
case IDCANCEL: // Close this dialog when clicking to close button
87-
case IDOK:
88-
if (pSelf)
89-
::SendMessage(pSelf->_hParent, NPPM_SETMENUITEMCHECK, static_cast<WPARAM>(pSelf->m_nCmdId), false);
90-
EndDialog(_hSelf, wParam);
91-
_hSelf = nullptr;
92-
return TRUE;
93-
}
94-
}
95-
}
96-
return FALSE;
39+
AboutDlg *pSelf = nullptr;
40+
switch (uMsg)
41+
{
42+
case WM_INITDIALOG:
43+
{
44+
::SetWindowLongPtr(_hSelf, DWLP_USER, lParam);
45+
46+
pSelf = reinterpret_cast<AboutDlg *>(static_cast<LONG_PTR>(::GetWindowLongPtr(_hSelf, DWLP_USER)));
47+
if (pSelf)
48+
{
49+
pSelf->SetVersion(_hSelf);
50+
}
51+
SetFocus(GetDlgItem(_hSelf, IDOK));
52+
53+
// Set links
54+
std::wstring urlIssue(TEXT("<a href=\"__URL__\">__URL__</a>"));
55+
std::wstring urlRepo = urlIssue;
56+
57+
urlIssue = StringHelper::ReplaceAll(urlIssue, TEXT("__URL__"), URL_REPORT_ISSUE);
58+
urlRepo = StringHelper::ReplaceAll(urlRepo, TEXT("__URL__"), URL_SOURCE_CODE);
59+
60+
SetWindowText(::GetDlgItem(_hSelf, IDC_WEB_ISSUE), urlIssue.c_str());
61+
SetWindowText(::GetDlgItem(_hSelf, IDC_WEB_SOURCE), urlRepo.c_str());
62+
63+
return TRUE;
64+
}
65+
66+
case WM_NOTIFY:
67+
{
68+
switch (reinterpret_cast<LPNMHDR>(lParam)->code)
69+
{
70+
case NM_CLICK:
71+
case NM_RETURN:
72+
{
73+
auto nmLink = reinterpret_cast<PNMLINK>(lParam);
74+
LITEM item = nmLink->item;
75+
76+
ShellExecute(nullptr, L"open", item.szUrl, nullptr, nullptr, SW_SHOW);
77+
return TRUE;
78+
}
79+
}
80+
return FALSE;
81+
}
82+
83+
case WM_COMMAND:
84+
{
85+
pSelf = reinterpret_cast<AboutDlg *>(static_cast<LONG_PTR>(::GetWindowLongPtr(_hSelf, DWLP_USER)));
86+
switch (LOWORD(wParam))
87+
{
88+
case IDCANCEL: // Close this dialog when clicking to close button
89+
case IDOK:
90+
if (pSelf)
91+
::SendMessage(pSelf->_hParent, NPPM_SETMENUITEMCHECK, static_cast<WPARAM>(pSelf->m_nCmdId), false);
92+
EndDialog(_hSelf, wParam);
93+
_hSelf = nullptr;
94+
return TRUE;
95+
}
96+
}
97+
}
98+
return FALSE;
9799
}
98100

99101
void AboutDlg::SetVersion(HWND hWnd)
100102
{
101-
std::wstring version;
102-
103-
// Get module path
104-
wchar_t moduleFileName[MAX_PATH + 1] = {};
105-
::GetModuleFileName(static_cast<HMODULE>(getHinst()), moduleFileName, _MAX_PATH);
106-
107-
version = CUtility::GetVersion(moduleFileName);
108-
if (!version.empty())
109-
{
110-
std::wstring text(PLUGIN_NAME);
111-
text += TEXT(" (");
112-
text += STR_VERSION;
113-
text += version;
114-
text += TEXT(") ");
115-
::SetWindowText(::GetDlgItem(hWnd, IDC_GB_TITLE), text.c_str());
116-
}
103+
std::wstring version;
104+
105+
// Get module path
106+
wchar_t moduleFileName[MAX_PATH + 1] = {};
107+
::GetModuleFileName(static_cast<HMODULE>(getHinst()), moduleFileName, _MAX_PATH);
108+
109+
version = CUtility::GetVersion(moduleFileName);
110+
if (!version.empty())
111+
{
112+
std::wstring text(PLUGIN_NAME);
113+
text += TEXT(" (");
114+
text += STR_VERSION;
115+
text += version;
116+
text += TEXT(") ");
117+
::SetWindowText(::GetDlgItem(hWnd, IDC_GB_TITLE), text.c_str());
118+
}
117119
}
118-

NppJSONViewer/NppJsonViewer/JsonViewDlg.cpp

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ HTREEITEM JsonViewDlg::InsertToTree(HTREEITEM parent, const std::string &text)
218218
void JsonViewDlg::UpdateNodePath(HTREEITEM htiNode)
219219
{
220220
std::wstring nodePath = m_hTreeView->GetNodePath(htiNode);
221-
SetDlgItemText(_hSelf, IDC_EDT_NODEPATH, nodePath.c_str());
221+
CUtility::SetEditCtrlText(::GetDlgItem(_hSelf, IDC_EDT_NODEPATH), nodePath);
222222
}
223223

224224
void JsonViewDlg::PrepareButtons()
@@ -262,7 +262,8 @@ void JsonViewDlg::SetIconAndTooltip(eButton ctrlType, const std::wstring &toolTi
262262
iconResID = IDI_ICON_SEARCH;
263263
break;
264264

265-
default: return;
265+
default:
266+
return;
266267
}
267268

268269
HWND hWnd = ::GetDlgItem(_hSelf, nCtrlID);
@@ -540,9 +541,13 @@ auto JsonViewDlg::GetFormatSetting() const -> std::tuple<LE, LF, char, unsigned>
540541
// End of line options
541542
switch (m_pSetting->lineEnding)
542543
{
543-
case LineEnding::WINDOWS: le = LE::kCrLf; break;
544+
case LineEnding::WINDOWS:
545+
le = LE::kCrLf;
546+
break;
544547

545-
case LineEnding::UNIX: le = LE::kLf; break;
548+
case LineEnding::UNIX:
549+
le = LE::kLf;
550+
break;
546551

547552
case LineEnding::MAC:
548553
le = LE::kCr;
@@ -555,9 +560,15 @@ auto JsonViewDlg::GetFormatSetting() const -> std::tuple<LE, LF, char, unsigned>
555560
const auto eol = m_Editor->GetEOL();
556561
switch (eol)
557562
{
558-
case 0: le = LE::kCrLf; break;
559-
case 1: le = LE::kCr; break;
560-
default: le = LE::kLf; break;
563+
case 0:
564+
le = LE::kCrLf;
565+
break;
566+
case 1:
567+
le = LE::kCr;
568+
break;
569+
default:
570+
le = LE::kLf;
571+
break;
561572
}
562573
}
563574
}
@@ -626,28 +637,47 @@ INT_PTR JsonViewDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
626637
{
627638
switch (LOWORD(wParam))
628639
{
629-
case IDC_BTN_REFRESH: DrawJsonTree(); break;
640+
// Handle Button events
641+
case IDC_BTN_REFRESH:
642+
DrawJsonTree();
643+
break;
630644

631-
case IDC_BTN_FORMAT: FormatJson(); break;
645+
case IDC_BTN_FORMAT:
646+
FormatJson();
647+
break;
632648

633-
case IDC_BTN_VALIDATE: ValidateJson(); break;
649+
case IDC_BTN_VALIDATE:
650+
ValidateJson();
651+
break;
634652

635653
case IDC_BTN_SEARCH:
636654
ShowMessage(L"OK", L"IDC_BTN_SEARCH", MB_OK);
637655
break;
638656

639-
// context menu entries
640-
case IDM_COPY_TREEITEM: CUtility::CopyToClipboard(CopyName(), _hSelf); break;
657+
// Handle context menu entries
658+
case IDM_COPY_TREEITEM:
659+
CUtility::CopyToClipboard(CopyName(), _hSelf);
660+
break;
641661

642-
case IDM_COPY_NODENAME: CUtility::CopyToClipboard(CopyKey(), _hSelf); break;
662+
case IDM_COPY_NODENAME:
663+
CUtility::CopyToClipboard(CopyKey(), _hSelf);
664+
break;
643665

644-
case IDM_COPY_NODEVALUE: CUtility::CopyToClipboard(CopyValue(), _hSelf); break;
666+
case IDM_COPY_NODEVALUE:
667+
CUtility::CopyToClipboard(CopyValue(), _hSelf);
668+
break;
645669

646-
case IDM_COPY_NODEPATH: CUtility::CopyToClipboard(CopyPath(), _hSelf); break;
670+
case IDM_COPY_NODEPATH:
671+
CUtility::CopyToClipboard(CopyPath(), _hSelf);
672+
break;
647673

648-
case IDM_EXPANDALL: ContextMenuExpand(true); break;
674+
case IDM_EXPANDALL:
675+
ContextMenuExpand(true);
676+
break;
649677

650-
case IDM_COLLAPSEALL: ContextMenuExpand(false); break;
678+
case IDM_COLLAPSEALL:
679+
ContextMenuExpand(false);
680+
break;
651681
}
652682
return TRUE;
653683
}

0 commit comments

Comments
 (0)