MCPcopy Create free account
hub / github.com/NPP-JSONViewer/JSON-Viewer / Apply

Method Apply

src/NppJsonViewer/SettingsDlg.cpp:89–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89bool SettingsDlg::Apply()
90{
91 // Get all the data from the UI
92
93 // Line Ending setting
94 if (IsDlgButtonChecked(_hSelf, IDC_RADIO_LINE_AUTO))
95 m_pSetting->lineEnding = LineEnding::AUTO;
96 else if (IsDlgButtonChecked(_hSelf, IDC_RADIO_LINE_WINDOW))
97 m_pSetting->lineEnding = LineEnding::WINDOWS;
98 else if (IsDlgButtonChecked(_hSelf, IDC_RADIO_LINE_UNIX))
99 m_pSetting->lineEnding = LineEnding::UNIX;
100 else if (IsDlgButtonChecked(_hSelf, IDC_RADIO_LINE_MAC))
101 m_pSetting->lineEnding = LineEnding::MAC;
102
103 // Indentation setting
104 if (IsDlgButtonChecked(_hSelf, IDC_RADIO_INDENT_AUTO))
105 m_pSetting->indent.style = IndentStyle::AUTO;
106 else if (IsDlgButtonChecked(_hSelf, IDC_RADIO_INDENT_TAB))
107 m_pSetting->indent.style = IndentStyle::TAB;
108 else if (IsDlgButtonChecked(_hSelf, IDC_RADIO_INDENT_SPACE))
109 m_pSetting->indent.style = IndentStyle::SPACE;
110
111 auto indent_len = CUtility::GetNumber(CUtility::GetEditCtrlText(::GetDlgItem(_hSelf, IDC_EDT_INDENT_SPACECOUNT)));
112 if (indent_len.has_value())
113 {
114 m_pSetting->indent.len = indent_len.value();
115 }
116
117 // Line Ending setting
118 if (IsDlgButtonChecked(_hSelf, IDC_RADIO_LINEFORMAT_DEFAULT))
119 m_pSetting->lineFormat = LineFormat::DEFAULT;
120 else if (IsDlgButtonChecked(_hSelf, IDC_RADIO_LINEFORMAT_SINGLE))
121 m_pSetting->lineFormat = LineFormat::SINGLELINE;
122
123 m_pSetting->bFollowCurrentTab = CUtility::GetCheckboxStatus(::GetDlgItem(_hSelf, IDC_CHK_FOLLOW_CURRENT_DOC));
124 m_pSetting->bAutoFormat = CUtility::GetCheckboxStatus(::GetDlgItem(_hSelf, IDC_CHK_FORMAT_ON_OPEN));
125 m_pSetting->bUseJsonHighlight = CUtility::GetCheckboxStatus(::GetDlgItem(_hSelf, IDC_CHK_JSON_HIGHLIGHT));
126 m_pSetting->parseOptions.bIgnoreTrailingComma = CUtility::GetCheckboxStatus(::GetDlgItem(_hSelf, IDC_CHK_IGNORE_COMMA));
127 m_pSetting->parseOptions.bIgnoreComment = CUtility::GetCheckboxStatus(::GetDlgItem(_hSelf, IDC_CHK_IGNORE_COMMENT));
128 m_pSetting->parseOptions.bReplaceUndefined = CUtility::GetCheckboxStatus(::GetDlgItem(_hSelf, IDC_CHK_REPLACE_UNDEFINED));
129
130 return WriteINI();
131}
132
133void SettingsDlg::destroy() {}
134

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected