Provide (experimental) clang-format file
[TortoiseGit.git] / src / TortoiseMerge / EncodingDlg.cpp
blob71d7a39101f682c3f9f1677f9f1bf58cf469392d
1 // TortoiseGitMerge - a Diff/Patch program
3 // Copyright (C) 2013 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "stdafx.h"
20 #include "EncodingDlg.h"
23 const CFileTextLines::UnicodeType uctArray[] =
25 CFileTextLines::ASCII,
26 CFileTextLines::UTF16_LE,
27 CFileTextLines::UTF16_BE,
28 CFileTextLines::UTF16_LEBOM,
29 CFileTextLines::UTF16_BEBOM,
30 CFileTextLines::UTF32_LE,
31 CFileTextLines::UTF32_BE,
32 CFileTextLines::UTF8,
33 CFileTextLines::UTF8BOM
36 const EOL eolArray[] =
38 EOL_AUTOLINE,
39 EOL_CRLF,
40 EOL_LF,
41 EOL_CR,
42 EOL_LFCR,
43 EOL_VT,
44 EOL_FF,
45 EOL_NEL,
46 EOL_LS,
47 EOL_PS
50 // dialog
52 IMPLEMENT_DYNAMIC(CEncodingDlg, CDialog)
54 CEncodingDlg::CEncodingDlg(CWnd* pParent)
55 : CDialog(CEncodingDlg::IDD, pParent)
56 , texttype(CFileTextLines::ASCII)
57 , lineendings(EOL_AUTOLINE)
61 CEncodingDlg::~CEncodingDlg()
65 void CEncodingDlg::DoDataExchange(CDataExchange* pDX)
67 CDialog::DoDataExchange(pDX);
68 DDX_Control(pDX, IDC_COMBO_ENCODING, m_Encoding);
69 DDX_Control(pDX, IDC_COMBO_EOL, m_EOL);
73 BEGIN_MESSAGE_MAP(CEncodingDlg, CDialog)
74 END_MESSAGE_MAP()
77 // message handlers
79 void CEncodingDlg::OnCancel()
81 __super::OnCancel();
84 void CEncodingDlg::OnOK()
86 UpdateData();
87 texttype = uctArray[m_Encoding.GetCurSel()];
88 lineendings = eolArray[m_EOL.GetCurSel()];
89 __super::OnOK();
92 BOOL CEncodingDlg::OnInitDialog()
94 CDialog::OnInitDialog();
96 CString sTitle;
97 GetWindowText(sTitle);
98 sTitle = view + sTitle;
99 SetWindowText(sTitle);
100 SetDlgItemText(IDC_VIEW, view);
102 for (int i = 0; i < _countof(uctArray); i++)
104 m_Encoding.AddString(CFileTextLines::GetEncodingName(uctArray[i]));
105 if (texttype == uctArray[i])
107 m_Encoding.SetCurSel(i);
111 for (int i = 0; i < _countof(eolArray); i++)
113 m_EOL.AddString(GetEolName(eolArray[i]));
114 if (lineendings == eolArray[i])
116 m_EOL.SetCurSel(i);
120 return FALSE;