Skip to content

Commit 8d8132f

Browse files
committed
Add few more settings to setting dialog
1 parent debd5bc commit 8d8132f

File tree

5 files changed

+36
-11
lines changed

5 files changed

+36
-11
lines changed

NppJSONViewer/NppJsonViewer/Define.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,16 @@ const TCHAR STR_COPYPATH[] = TEXT("Copy path");
4646
const TCHAR STR_EXPANDALL[] = TEXT("Expand all");
4747
const TCHAR STR_COLLAPSEALL[] = TEXT("Collapse all");
4848

49-
const TCHAR STR_INI_FORMATTING_SEC[] = TEXT("FORMATTING");
49+
const TCHAR STR_INI_FORMATTING_SEC[] = TEXT("Formatting");
5050
const TCHAR STR_INI_FORMATTING_EOL[] = TEXT("EOL");
5151
const TCHAR STR_INI_FORMATTING_LINE[] = TEXT("LINE_FORMATTING");
5252
const TCHAR STR_INI_FORMATTING_INDENT[] = TEXT("INDENTATION");
5353
const TCHAR STR_INI_FORMATTING_INDENTCOUNT[] = TEXT("INDENTATION_COUNT");
5454

55+
const TCHAR STR_INI_OTHER_SEC[] = TEXT("Others");
56+
const TCHAR STR_INI_OTHER_FOLLOW_TAB[] = TEXT("FOLLOW_TAB");
57+
const TCHAR STR_INI_OTHER_AUTO_FORMAT[] = TEXT("AUTO_FORMAT");
58+
5559
enum class IndentStyle { AUTO, TAB, SPACE };
5660
struct Indent
5761
{
@@ -67,5 +71,7 @@ struct Setting
6771
LineEnding le = LineEnding::AUTO;
6872
LineFormat lf = LineFormat::DEFAULT;
6973
Indent indent{};
74+
bool follow_current_tab = false;
75+
bool auto_format_on_open = false;
7076
};
7177

NppJSONViewer/NppJsonViewer/Profile.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,14 @@ bool ProfileSetting::GetSettings(Setting& info) const
9090
if (bRetVal)
9191
info.indent.len = nVal;
9292

93+
bRetVal &= ReadValue(STR_INI_OTHER_SEC, STR_INI_OTHER_FOLLOW_TAB, nVal);
94+
if (bRetVal)
95+
info.follow_current_tab = static_cast<bool>(nVal);
96+
97+
bRetVal &= ReadValue(STR_INI_OTHER_SEC, STR_INI_OTHER_AUTO_FORMAT, nVal);
98+
if (bRetVal)
99+
info.auto_format_on_open = static_cast<bool>(nVal);
100+
93101
return bRetVal;
94102
}
95103

@@ -101,6 +109,8 @@ bool ProfileSetting::SetSettings(const Setting& info) const
101109
bRetVal &= WriteValue(STR_INI_FORMATTING_SEC, STR_INI_FORMATTING_LINE, static_cast<int>(info.lf));
102110
bRetVal &= WriteValue(STR_INI_FORMATTING_SEC, STR_INI_FORMATTING_INDENT, static_cast<int>(info.indent.style));
103111
bRetVal &= WriteValue(STR_INI_FORMATTING_SEC, STR_INI_FORMATTING_INDENTCOUNT, info.indent.len);
112+
bRetVal &= WriteValue(STR_INI_OTHER_SEC, STR_INI_OTHER_FOLLOW_TAB, info.follow_current_tab);
113+
bRetVal &= WriteValue(STR_INI_OTHER_SEC, STR_INI_OTHER_AUTO_FORMAT, info.auto_format_on_open);
104114

105115
return bRetVal;
106116
}

NppJSONViewer/NppJsonViewer/SettingsDlg.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ bool SettingsDlg::Apply()
123123
else if (IsDlgButtonChecked(_hSelf, IDC_RADIO_LINEFORMAT_SINGLE))
124124
m_pSetting->lf = LineFormat::SINGLELINE;
125125

126+
m_pSetting->follow_current_tab = CUtility::GetCheckboxStatus(::GetDlgItem(_hSelf, IDC_CHK_FOLLOW_CURRENT_DOC));
127+
m_pSetting->auto_format_on_open = CUtility::GetCheckboxStatus(::GetDlgItem(_hSelf, IDC_CHK_FORMAT_ON_OPEN));
128+
126129
return WriteINI();
127130
}
128131

@@ -179,6 +182,8 @@ void SettingsDlg::InitDlg()
179182
CUtility::SetEditCtrlText(::GetDlgItem(_hSelf, IDC_EDT_INDENT_SPACECOUNT), std::to_wstring(m_pSetting->indent.len));
180183
ShowSpaceCountCtrls(m_pSetting->indent.style == IndentStyle::SPACE);
181184

185+
CUtility::SetCheckboxStatus(::GetDlgItem(_hSelf, IDC_CHK_FOLLOW_CURRENT_DOC), m_pSetting->follow_current_tab);
186+
CUtility::SetCheckboxStatus(::GetDlgItem(_hSelf, IDC_CHK_FORMAT_ON_OPEN), m_pSetting->auto_format_on_open);
182187
}
183188

184189
void SettingsDlg::ShowSpaceCountCtrls(bool bShow)

NppJSONViewer/NppJsonViewer/resource.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
#define IDC_STATIC_SPACECOUNT 1024
3737
#define IDC_RADIO_LINEFORMAT_DEFAULT 1025
3838
#define IDC_RADIO_LINEFORMAT_SINGLE 1026
39+
#define IDC_CHK_FOLLOW_CURRENT_DOC 1028
40+
#define IDC_CHK_FORMAT_ON_OPEN 1029
3941
#define IDM_COPY_TREEITEM 40001
4042
#define IDM_COPY_NODENAME 40002
4143
#define IDM_COPY_NODEVALUE 40003
@@ -49,7 +51,7 @@
4951
#ifndef APSTUDIO_READONLY_SYMBOLS
5052
#define _APS_NEXT_RESOURCE_VALUE 110
5153
#define _APS_NEXT_COMMAND_VALUE 40007
52-
#define _APS_NEXT_CONTROL_VALUE 1027
54+
#define _APS_NEXT_CONTROL_VALUE 1030
5355
#define _APS_NEXT_SYMED_VALUE 101
5456
#endif
5557
#endif

NppJSONViewer/NppJsonViewer/resource.rc

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,24 @@ CAPTION "JSON Viewer Settings"
9797
FONT 8, "MS Shell Dlg", 400, 0, 0x1
9898
BEGIN
9999
PUSHBUTTON "",IDC_HOR_BAR_TOP,0,1,300,1,WS_DISABLED,WS_EX_STATICEDGE
100-
GROUPBOX " Line Ending: ",IDC_STATIC,7,7,140,43
101-
CONTROL "Auto detect",IDC_RADIO_LINE_AUTO,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,14,21,50,10
102-
CONTROL "Window (CR LF)",IDC_RADIO_LINE_WINDOW,"Button",BS_AUTORADIOBUTTON,72,21,65,10
103-
CONTROL "Unix (LF)",IDC_RADIO_LINE_UNIX,"Button",BS_AUTORADIOBUTTON,14,33,50,10
104-
CONTROL "Macintosh (LF)",IDC_RADIO_LINE_MAC,"Button",BS_AUTORADIOBUTTON,72,33,65,10
100+
CONTROL "Follow current tab",IDC_CHK_FOLLOW_CURRENT_DOC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,7,140,10
101+
CONTROL "Auto format josn file when openend",IDC_CHK_FORMAT_ON_OPEN,
102+
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,20,140,10
105103
GROUPBOX " Indentation: ",IDC_STATIC,153,7,140,43
106104
CONTROL "Auto detect",IDC_RADIO_INDENT_AUTO,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,160,21,50,10
107105
CONTROL "Use tab",IDC_RADIO_INDENT_TAB,"Button",BS_AUTORADIOBUTTON,240,21,50,10
108106
CONTROL "Use space",IDC_RADIO_INDENT_SPACE,"Button",BS_AUTORADIOBUTTON,160,33,50,10
109107
LTEXT "Count:",IDC_STATIC_SPACECOUNT,240,33,24,8
110108
EDITTEXT IDC_EDT_INDENT_SPACECOUNT,266,32,20,11,ES_AUTOHSCROLL | ES_NUMBER
111-
GROUPBOX " Line formating: ",IDC_STATIC,7,57,140,43
112-
CONTROL "Default formatting",IDC_RADIO_LINEFORMAT_DEFAULT,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,14,71,110,10
109+
GROUPBOX " Line Ending: ",IDC_STATIC,153,52,140,43
110+
CONTROL "Auto detect",IDC_RADIO_LINE_AUTO,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,160,66,50,10
111+
CONTROL "Window (CR LF)",IDC_RADIO_LINE_WINDOW,"Button",BS_AUTORADIOBUTTON,218,66,65,10
112+
CONTROL "Unix (LF)",IDC_RADIO_LINE_UNIX,"Button",BS_AUTORADIOBUTTON,160,78,50,10
113+
CONTROL "Macintosh (LF)",IDC_RADIO_LINE_MAC,"Button",BS_AUTORADIOBUTTON,218,78,65,10
114+
GROUPBOX " Line formating: ",IDC_STATIC,153,97,140,43
115+
CONTROL "Default formatting",IDC_RADIO_LINEFORMAT_DEFAULT,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,160,111,110,10
113116
CONTROL "Format arrays on a single line",IDC_RADIO_LINEFORMAT_SINGLE,
114-
"Button",BS_AUTORADIOBUTTON,14,83,110,10
117+
"Button",BS_AUTORADIOBUTTON,160,123,110,10
115118
PUSHBUTTON "",IDC_HOR_BAR_BOTTOM,0,145,300,1,WS_DISABLED,WS_EX_STATICEDGE
116119
DEFPUSHBUTTON "OK",IDOK,185,151,50,14
117120
PUSHBUTTON "Cancel",IDCANCEL,243,151,50,14
@@ -205,7 +208,6 @@ BEGIN
205208
0
206209
END
207210

208-
209211
IDD_SETTING AFX_DIALOG_LAYOUT
210212
BEGIN
211213
0

0 commit comments

Comments
 (0)