Permalink
Browse files

Add inconsistent line endings warning option, issue #37.

  • Loading branch information...
zufuliu committed Oct 20, 2018
1 parent ddaf334 commit 8b6c757e8a34e69adb8e2166b31fea01eefa9fad
Showing with 22 additions and 13 deletions.
  1. +10 −8 src/Dialogs.c
  2. +4 −1 src/Notepad2.c
  3. +6 −4 src/Notepad2.rc
  4. +2 −0 src/resource.h
@@ -40,6 +40,7 @@ extern BOOL bLoadASCIIasUTF8;
extern BOOL bLoadNFOasOEM;
extern int fNoFileVariables;
extern BOOL bNoEncodingTags;
extern BOOL bWarnInconsistentLineEndings;
extern BOOL bFixLineEndings;
extern BOOL bAutoStripBlanks;
extern WCHAR szCurFile[MAX_PATH + 40];
@@ -1901,10 +1902,6 @@ BOOL RecodeDlg(HWND hwnd, int *pidREncoding) {
//
// SelectDefLineEndingDlgProc()
//
// Controls: 100 Combo
// IDC_CONSISTENTEOLS
// IDC_AUTOSTRIPBLANKS
//
INT_PTR CALLBACK SelectDefLineEndingDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) {
static int *piOption;
@@ -1917,11 +1914,15 @@ INT_PTR CALLBACK SelectDefLineEndingDlgProc(HWND hwnd, UINT umsg, WPARAM wParam,
// Load options
for (int i = 0; i < 3; i++) {
GetString(IDS_EOLMODENAME0 + i, wch, COUNTOF(wch));
SendDlgItemMessage(hwnd, 100, CB_ADDSTRING, 0, (LPARAM)wch);
SendDlgItemMessage(hwnd, IDC_EOLMODELIST, CB_ADDSTRING, 0, (LPARAM)wch);
}
SendDlgItemMessage(hwnd, 100, CB_SETCURSEL, (WPARAM)(*piOption), 0);
SendDlgItemMessage(hwnd, 100, CB_SETEXTENDEDUI, TRUE, 0);
SendDlgItemMessage(hwnd, IDC_EOLMODELIST, CB_SETCURSEL, (WPARAM)(*piOption), 0);
SendDlgItemMessage(hwnd, IDC_EOLMODELIST, CB_SETEXTENDEDUI, TRUE, 0);
if (bWarnInconsistentLineEndings) {
CheckDlgButton(hwnd, IDC_WARNINCONSISTENTEOLS, BST_CHECKED);
}
if (bFixLineEndings) {
CheckDlgButton(hwnd, IDC_CONSISTENTEOLS, BST_CHECKED);
@@ -1938,7 +1939,8 @@ INT_PTR CALLBACK SelectDefLineEndingDlgProc(HWND hwnd, UINT umsg, WPARAM wParam,
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK: {
*piOption = (int)SendDlgItemMessage(hwnd, 100, CB_GETCURSEL, 0, 0);
*piOption = (int)SendDlgItemMessage(hwnd, IDC_EOLMODELIST, CB_GETCURSEL, 0, 0);
bWarnInconsistentLineEndings = IsButtonChecked(hwnd, IDC_WARNINCONSISTENTEOLS);
bFixLineEndings = IsButtonChecked(hwnd, IDC_CONSISTENTEOLS);
bAutoStripBlanks = IsButtonChecked(hwnd, IDC_AUTOSTRIPBLANKS);
EndDialog(hwnd, IDOK);
@@ -166,6 +166,7 @@ BOOL bNoEncodingTags;
int iSrcEncoding = -1;
int iWeakSrcEncoding = -1;
int iDefaultEOLMode;
BOOL bWarnInconsistentLineEndings;
BOOL bFixLineEndings;
BOOL bAutoStripBlanks;
int iPrintHeader;
@@ -5458,6 +5459,7 @@ void LoadSettings(void) {
iDefaultEOLMode = IniSectionGetInt(pIniSection, L"DefaultEOLMode", 0);
iDefaultEOLMode = clamp_i(iDefaultEOLMode, SC_EOL_CRLF, SC_EOL_LF);
bWarnInconsistentLineEndings = IniSectionGetBool(pIniSection, L"WarnInconsistentLineEndings", 1);
bFixLineEndings = IniSectionGetBool(pIniSection, L"FixLineEndings", 1);
bAutoStripBlanks = IniSectionGetBool(pIniSection, L"FixTrailingBlanks", 0);
@@ -5729,6 +5731,7 @@ void SaveSettings(BOOL bSaveSettingsNow) {
IniSectionSetBoolEx(pIniSection, L"LoadNFOasOEM", bLoadNFOasOEM, 1);
IniSectionSetBoolEx(pIniSection, L"NoEncodingTags", bNoEncodingTags, 0);
IniSectionSetIntEx(pIniSection, L"DefaultEOLMode", iDefaultEOLMode, 0);
IniSectionSetIntEx(pIniSection, L"WarnInconsistentLineEndings", bWarnInconsistentLineEndings, 1);
IniSectionSetBoolEx(pIniSection, L"FixLineEndings", bFixLineEndings, 1);
IniSectionSetBoolEx(pIniSection, L"FixTrailingBlanks", bAutoStripBlanks, 0);
@@ -7115,7 +7118,7 @@ BOOL FileLoad(BOOL bDontSave, BOOL bNew, BOOL bReload, BOOL bNoEncDetect, LPCWST
MsgBox(MBWARN, IDS_ERR_UNICODE);
}
// Show inconsistent line endings warning
if (status.bInconsistent) {
if (status.bInconsistent && bWarnInconsistentLineEndings) {
}
} else if (!status.bFileTooBig) {
MsgBox(MBWARN, IDS_ERR_LOADFILE, szFileName);
@@ -987,17 +987,19 @@ BEGIN
PUSHBUTTON "Cancel",IDCANCEL,152,88,50,14
END
IDD_DEFEOLMODE DIALOGEX 0, 0, 196, 78
IDD_DEFEOLMODE DIALOGEX 0, 0, 196, 80
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Line Endings"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
LTEXT "&Default line ending mode:",IDC_STATIC,7,7,116,8
COMBOBOX 100,7,20,118,81,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_EOLMODELIST,7,20,118,81,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Show inconsistent line endings warning on loading.",IDC_WARNINCONSISTENTEOLS,
"Button",BS_AUTOCHECKBOX | BS_VCENTER | WS_TABSTOP,7,40,186,10
CONTROL "&Ensure consistent line endings when saving.",IDC_CONSISTENTEOLS,
"Button",BS_AUTOCHECKBOX | BS_VCENTER | WS_TABSTOP,7,48,182,10
"Button",BS_AUTOCHECKBOX | BS_VCENTER | WS_TABSTOP,7,52,182,10
CONTROL "&Strip trailing blanks when saving.",IDC_AUTOSTRIPBLANKS,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,60,173,10
"Button",BS_AUTOCHECKBOX | BS_VCENTER | WS_TABSTOP,7,64,173,10
DEFPUSHBUTTON "OK",IDOK,139,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,139,24,50,14
END
@@ -16,6 +16,7 @@
#define IDC_INFOBOXICON 100
#define IDC_COPY 100
#define IDC_ENCODINGLIST 100
#define IDC_EOLMODELIST 100
#define IDC_SEARCHEXE 101
#define IDR_POPUPMENU 101
#define IDC_GETOPENWITHDIR 101
@@ -32,6 +33,7 @@
#define IDC_STYLELABEL 101
#define IDC_RESIZEGRIP4 101
#define IDC_NOUNICODEDETECTION 101
#define IDC_WARNINCONSISTENTEOLS 101
#define IDC_STYLEEDIT 102
#define IDC_FINDCASE 102
#define IDC_OPENWITHDESCR 102

0 comments on commit 8b6c757

Please sign in to comment.