From 35deb8a303cbe6f2d4902c0aed1ab0ed17c749e7 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Thu, 29 Feb 2024 17:51:27 +0100 Subject: [PATCH] Make "Prevent C0 input" feature optional --- PowerEditor/installer/nativeLang/english.xml | 2 +- PowerEditor/installer/nativeLang/english_customizable.xml | 2 +- PowerEditor/installer/nativeLang/french.xml | 2 +- PowerEditor/src/Parameters.cpp | 2 ++ PowerEditor/src/Parameters.h | 1 + PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp | 3 ++- PowerEditor/src/WinControls/Preference/preference.rc | 4 ++-- PowerEditor/src/WinControls/Preference/preferenceDlg.cpp | 7 +++++++ PowerEditor/src/WinControls/Preference/preference_rc.h | 2 +- 9 files changed, 18 insertions(+), 7 deletions(-) diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 50bb17065..5048d71a7 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -1008,7 +1008,7 @@ Translation note: - + diff --git a/PowerEditor/installer/nativeLang/english_customizable.xml b/PowerEditor/installer/nativeLang/english_customizable.xml index 2b47ef179..a19a69f79 100644 --- a/PowerEditor/installer/nativeLang/english_customizable.xml +++ b/PowerEditor/installer/nativeLang/english_customizable.xml @@ -1008,7 +1008,7 @@ Translation note: - + diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml index 5ef7c621e..e475f6bb3 100644 --- a/PowerEditor/installer/nativeLang/french.xml +++ b/PowerEditor/installer/nativeLang/french.xml @@ -1006,7 +1006,7 @@ Translation note: - + diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 3f1b9f236..82ea68f8a 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -6569,6 +6569,7 @@ void NppParameters::feedScintillaParam(TiXmlNode *node) _svp._npcCustomColor = parseYesNoBoolAttribute(TEXT("npcCustomColor")); _svp._npcIncludeCcUniEol = parseYesNoBoolAttribute(TEXT("npcIncludeCcUniEOL")); + _svp._npcNoInputC0 = parseYesNoBoolAttribute(TEXT("npcNoInputC0")); // C0, C1 control and Unicode EOL visibility state _svp._ccUniEolShow = parseYesNoBoolAttribute(TEXT("ccShow"), true); @@ -6905,6 +6906,7 @@ bool NppParameters::writeScintillaParams() (scintNode->ToElement())->SetAttribute(TEXT("npcMode"), static_cast(_svp._npcMode)); setYesNoBoolAttribute(TEXT("npcCustomColor"), _svp._npcCustomColor); setYesNoBoolAttribute(TEXT("npcIncludeCcUniEOL"), _svp._npcIncludeCcUniEol); + setYesNoBoolAttribute(TEXT("npcNoInputC0"), _svp._npcNoInputC0); setYesNoBoolAttribute(TEXT("ccShow"), _svp._ccUniEolShow); (scintNode->ToElement())->SetAttribute(TEXT("borderWidth"), _svp._borderWidth); (scintNode->ToElement())->SetAttribute(TEXT("smoothFont"), _svp._doSmoothFont ? TEXT("yes") : TEXT("no")); diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 4d4c34f12..8a18963e7 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -967,6 +967,7 @@ struct ScintillaViewParams bool _npcCustomColor = false; bool _npcIncludeCcUniEol = false; bool _ccUniEolShow = true; + bool _npcNoInputC0 = true; int _borderWidth = 2; bool _virtualSpace = false; diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp index ebd16d0b0..7366282d4 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp @@ -501,7 +501,8 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa { // prevent "control characters" from being entered in text // (don't need to be concerned about Tab or CR or LF etc here) - if ((wParam >= 0 && wParam <= 31) || wParam == 127) + if ((NppParameters::getInstance()).getSVP()._npcNoInputC0 && + ((wParam >= 0 && wParam <= 31) || wParam == 127)) { return FALSE; } diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index 55cf9f9b8..81da1a58a 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -126,8 +126,8 @@ BEGIN CONTROL "Codepoint",IDC_RADIO_NPC_CODEPOINT,"Button",BS_AUTORADIOBUTTON,33,116,110,10 CONTROL "Custom Color",IDC_CHECK_NPC_COLOR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,33,133,110,10 PUSHBUTTON "...",IDC_BUTTON_NPC_LAUNCHSTYLECONF,147,130,16,14 - CONTROL "Apply appearance settings to C0, C1 && Unicode EOL",IDC_CHECK_NPC_INCLUDECCUNIEOL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,153,281,10 - //CONTROL "Prevent control character (C0 code) typing into document",IDC_CHECK_NPC_NOC0CODETYPING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,177,281,10 + CONTROL "Apply Appearance settings to C0, C1 && Unicode EOL",IDC_CHECK_NPC_INCLUDECCUNIEOL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,153,281,10 + CONTROL "Prevent control character (C0 code) typing into document", IDC_CHECK_NPC_NOINPUTC0,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,177,281,10 END diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index c17ef9a70..7bf35b3c8 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -1182,6 +1182,7 @@ intptr_t CALLBACK Editing2SubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA setChecked(IDC_CHECK_NPC_COLOR, svp._npcCustomColor); setChecked(IDC_CHECK_NPC_INCLUDECCUNIEOL, svp._npcIncludeCcUniEol); + setChecked(IDC_CHECK_NPC_NOINPUTC0, svp._npcNoInputC0); generic_string tipNote2Show = pNativeSpeaker->getLocalizedStrFromID("npcNote-tip", L"Representation of selected \"non-ASCII\" whitespace and non-printing (control) characters.\n\n"\ @@ -1370,6 +1371,12 @@ intptr_t CALLBACK Editing2SubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA ::SendMessage(grandParent, NPPM_INTERNAL_SETNPC, IDC_CHECK_NPC_INCLUDECCUNIEOL, 0); return TRUE; } + + case IDC_CHECK_NPC_NOINPUTC0: + { + svp._npcNoInputC0 = isCheckedOrNot(IDC_CHECK_NPC_NOINPUTC0); + return TRUE; + } } } return TRUE; diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index 7b4ac6292..e746c0226 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -166,7 +166,7 @@ #define IDC_CHECK_NPC_COLOR (IDD_PREFERENCE_SUB_EDITING + 56) #define IDC_BUTTON_NPC_LAUNCHSTYLECONF (IDD_PREFERENCE_SUB_EDITING + 57) #define IDC_CHECK_NPC_INCLUDECCUNIEOL (IDD_PREFERENCE_SUB_EDITING + 58) - #define IDC_CHECK_NPC_NOC0CODETYPING (IDD_PREFERENCE_SUB_EDITING + 59) + #define IDC_CHECK_NPC_NOINPUTC0 (IDD_PREFERENCE_SUB_EDITING + 59) #define IDC_STATIC_NPC_APPEARANCE (IDD_PREFERENCE_SUB_EDITING + 60) #define IDD_PREFERENCE_SUB_DELIMITER 6250 //(IDD_PREFERENCE_BOX + 250)