From 88ed851478b3426e9cca365b67a1ceb4cd4f92e2 Mon Sep 17 00:00:00 2001 From: Manuel Montoto Date: Wed, 30 Mar 2022 03:02:13 +0200 Subject: [PATCH] Add virtual space ability Added an option in preferences to enable or disable virtual space. Fix #11443, Fix #11444, close #11452 --- PowerEditor/installer/nativeLang/basque.xml | 1 + PowerEditor/installer/nativeLang/catalan.xml | 1 + PowerEditor/installer/nativeLang/english.xml | 1 + .../installer/nativeLang/english_customizable.xml | 1 + PowerEditor/installer/nativeLang/galician.xml | 1 + PowerEditor/installer/nativeLang/spanish.xml | 1 + PowerEditor/src/Notepad_plus.cpp | 8 ++++++-- PowerEditor/src/NppBigSwitch.cpp | 14 ++++++++++++++ PowerEditor/src/Parameters.cpp | 11 +++++++++++ PowerEditor/src/Parameters.h | 1 + .../src/WinControls/Preference/preference.rc | 7 ++++--- .../src/WinControls/Preference/preferenceDlg.cpp | 6 ++++++ .../src/WinControls/Preference/preference_rc.h | 2 ++ PowerEditor/src/resource.h | 1 + 14 files changed, 51 insertions(+), 5 deletions(-) diff --git a/PowerEditor/installer/nativeLang/basque.xml b/PowerEditor/installer/nativeLang/basque.xml index f13a52f6d..8c02fb5bf 100644 --- a/PowerEditor/installer/nativeLang/basque.xml +++ b/PowerEditor/installer/nativeLang/basque.xml @@ -859,6 +859,7 @@ The comments are here for explanation, it's not necessary to translate them. + diff --git a/PowerEditor/installer/nativeLang/catalan.xml b/PowerEditor/installer/nativeLang/catalan.xml index 8f87156d1..f5c68ea75 100644 --- a/PowerEditor/installer/nativeLang/catalan.xml +++ b/PowerEditor/installer/nativeLang/catalan.xml @@ -747,6 +747,7 @@ By Hiro5 + diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index aebeab525..de6f02bd9 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -884,6 +884,7 @@ The comments are here for explanation, it's not necessary to translate them. + diff --git a/PowerEditor/installer/nativeLang/english_customizable.xml b/PowerEditor/installer/nativeLang/english_customizable.xml index 75aa34d44..a826aed68 100644 --- a/PowerEditor/installer/nativeLang/english_customizable.xml +++ b/PowerEditor/installer/nativeLang/english_customizable.xml @@ -844,6 +844,7 @@ + diff --git a/PowerEditor/installer/nativeLang/galician.xml b/PowerEditor/installer/nativeLang/galician.xml index e11bab2ee..1efb37e1b 100644 --- a/PowerEditor/installer/nativeLang/galician.xml +++ b/PowerEditor/installer/nativeLang/galician.xml @@ -341,6 +341,7 @@ + diff --git a/PowerEditor/installer/nativeLang/spanish.xml b/PowerEditor/installer/nativeLang/spanish.xml index 0cff68485..f12840104 100644 --- a/PowerEditor/installer/nativeLang/spanish.xml +++ b/PowerEditor/installer/nativeLang/spanish.xml @@ -844,6 +844,7 @@ The comments are here for explanation, it's not necessary to translate them. + diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 3f786e38d..8a8064911 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -319,8 +319,12 @@ LRESULT Notepad_plus::init(HWND hwnd) _subEditView.execute(SCI_SETADDITIONALSELECTIONTYPING, true); // Turn virtual space on - _mainEditView.execute(SCI_SETVIRTUALSPACEOPTIONS, SCVS_RECTANGULARSELECTION); - _subEditView.execute(SCI_SETVIRTUALSPACEOPTIONS, SCVS_RECTANGULARSELECTION); + int virtualSpaceOptions = SCVS_RECTANGULARSELECTION; + if(svp._virtualSpace) + virtualSpaceOptions |= SCVS_USERACCESSIBLE | SCVS_NOWRAPLINESTART; + + _mainEditView.execute(SCI_SETVIRTUALSPACEOPTIONS, virtualSpaceOptions); + _subEditView.execute(SCI_SETVIRTUALSPACEOPTIONS, virtualSpaceOptions); // Turn multi-paste on _mainEditView.execute(SCI_SETMULTIPASTE, SC_MULTIPASTE_EACH); diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 75ea065f4..246dd244d 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -1571,6 +1571,20 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa return TRUE; } + case NPPM_INTERNAL_VIRTUALSPACE: + { + const bool virtualSpace = (nppParam.getSVP())._virtualSpace; + + int virtualSpaceOptions = SCVS_RECTANGULARSELECTION; + if(virtualSpace) + virtualSpaceOptions |= SCVS_USERACCESSIBLE | SCVS_NOWRAPLINESTART; + + _mainEditView.execute(SCI_SETVIRTUALSPACEOPTIONS, virtualSpaceOptions); + _subEditView.execute(SCI_SETVIRTUALSPACEOPTIONS, virtualSpaceOptions); + + return TRUE; + } + case NPPM_INTERNAL_SCROLLBEYONDLASTLINE: { const bool endAtLastLine = !(nppParam.getSVP())._scrollBeyondLastLine; diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 7ded6ebea..8c61bf986 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -5674,6 +5674,16 @@ void NppParameters::feedScintillaParam(TiXmlNode *node) _svp._currentLineHilitingShow = false; } + // Virtual Space + nm = element->Attribute(TEXT("virtualSpace")); + if (nm) + { + if (!lstrcmp(nm, TEXT("yes"))) + _svp._virtualSpace = true; + else if (!lstrcmp(nm, TEXT("no"))) + _svp._virtualSpace = false; + } + // Scrolling Beyond Last Line State nm = element->Attribute(TEXT("scrollBeyondLastLine")); if (nm) @@ -6051,6 +6061,7 @@ bool NppParameters::writeScintillaParams() (scintNode->ToElement())->SetAttribute(TEXT("lineWrapMethod"), pWrapMethodStr); (scintNode->ToElement())->SetAttribute(TEXT("currentLineHilitingShow"), _svp._currentLineHilitingShow?TEXT("show"):TEXT("hide")); + (scintNode->ToElement())->SetAttribute(TEXT("virtualSpace"), _svp._virtualSpace?TEXT("yes"):TEXT("no")); (scintNode->ToElement())->SetAttribute(TEXT("scrollBeyondLastLine"), _svp._scrollBeyondLastLine?TEXT("yes"):TEXT("no")); (scintNode->ToElement())->SetAttribute(TEXT("rightClickKeepsSelection"), _svp._rightClickKeepsSelection ? TEXT("yes") : TEXT("no")); (scintNode->ToElement())->SetAttribute(TEXT("disableAdvancedScrolling"), _svp._disableAdvancedScrolling?TEXT("yes"):TEXT("no")); diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 9e62e3f02..37dc8978a 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -885,6 +885,7 @@ struct ScintillaViewParams bool _whiteSpaceShow = false; bool _eolShow = false; int _borderWidth = 2; + bool _virtualSpace = false; bool _scrollBeyondLastLine = true; bool _rightClickKeepsSelection = false; bool _disableAdvancedScrolling = false; diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index 4f5542dd0..420cb9e60 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -87,9 +87,10 @@ BEGIN CONTROL "Enable Multi-Editing (Ctrl+Mouse click/selection)",IDC_CHECK_MULTISELECTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54,90,270,10 CONTROL "Enable current line highlighting",IDC_CHECK_CURRENTLINEHILITE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54,103,270,10 CONTROL "Enable smooth font",IDC_CHECK_SMOOTHFONT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54,116,250,10 - CONTROL "Enable scrolling beyond last line",IDC_CHECK_SCROLLBEYONDLASTLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54,129,270,10 - CONTROL "Keep selection when right-click outside of selection",IDC_CHECK_RIGHTCLICKKEEPSSELECTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54,142,270,10 - CONTROL "Disable advanced scrolling feature due to touchpad issue",IDC_CHECK_DISABLEADVANCEDSCROLL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54,155,270,10 + CONTROL "Enable virtual space",IDC_CHECK_VIRTUALSPACE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54,129,270,10 + CONTROL "Enable scrolling beyond last line",IDC_CHECK_SCROLLBEYONDLASTLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54,142,270,10 + CONTROL "Keep selection when right-click outside of selection",IDC_CHECK_RIGHTCLICKKEEPSSELECTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54,155,270,10 + CONTROL "Disable advanced scrolling feature due to touchpad issue",IDC_CHECK_DISABLEADVANCEDSCROLL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,54,168,270,10 END IDD_PREFERENCE_SUB_DARKMODE DIALOGEX 0, 0, 455, 185 diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index b907ba58e..2ec16cb93 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -700,6 +700,7 @@ void EditingSubDlg::initScintParam() ::SendDlgItemMessage(_hSelf, IDC_CHECK_SMOOTHFONT, BM_SETCHECK, svp._doSmoothFont, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_CURRENTLINEHILITE, BM_SETCHECK, svp._currentLineHilitingShow, 0); + ::SendDlgItemMessage(_hSelf, IDC_CHECK_VIRTUALSPACE, BM_SETCHECK, svp._virtualSpace, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_SCROLLBEYONDLASTLINE, BM_SETCHECK, svp._scrollBeyondLastLine, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_RIGHTCLICKKEEPSSELECTION, BM_SETCHECK, svp._rightClickKeepsSelection, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_DISABLEADVANCEDSCROLL, BM_SETCHECK, svp._disableAdvancedScrolling, 0); @@ -811,6 +812,11 @@ intptr_t CALLBACK EditingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_CURLINE_HILITING, 0); return TRUE; + case IDC_CHECK_VIRTUALSPACE: + svp._virtualSpace = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_CHECK_VIRTUALSPACE, BM_GETCHECK, 0, 0)); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_VIRTUALSPACE, 0, 0); + return TRUE; + case IDC_CHECK_SCROLLBEYONDLASTLINE: svp._scrollBeyondLastLine = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_CHECK_SCROLLBEYONDLASTLINE, BM_GETCHECK, 0, 0)); ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SCROLLBEYONDLASTLINE, 0, 0); diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index acd5b8ddf..c8779572a 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -134,6 +134,8 @@ #define IDC_PADDINGRIGHTVAL_STATIC (IDD_PREFERENCE_SUB_EDITING + 43) #define IDC_DISTRACTIONFREEVAL_STATIC (IDD_PREFERENCE_SUB_EDITING + 44) + #define IDC_CHECK_VIRTUALSPACE (IDD_PREFERENCE_SUB_EDITING + 45) + #define IDD_PREFERENCE_SUB_DELIMITER 6250 //(IDD_PREFERENCE_BOX + 250) #define IDC_DELIMITERSETTINGS_GB_STATIC (IDD_PREFERENCE_SUB_DELIMITER + 1) #define IDD_STATIC_OPENDELIMITER (IDD_PREFERENCE_SUB_DELIMITER + 2) diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index 0488b86bd..a6a402c24 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -635,6 +635,7 @@ #define NPPM_INTERNAL_REFRESHDARKMODE (NOTEPADPLUS_USER_INTERNAL + 59) #define NPPM_INTERNAL_SCINTILLAFINDERCOPYPATHS (NOTEPADPLUS_USER_INTERNAL + 60) #define NPPM_INTERNAL_REFRESHWORKDIR (NOTEPADPLUS_USER_INTERNAL + 61) + #define NPPM_INTERNAL_VIRTUALSPACE (NOTEPADPLUS_USER_INTERNAL + 62) // See Notepad_plus_msgs.h //#define NOTEPADPLUS_USER (WM_USER + 1000)