From 1a9307b02d3381a77e033784edff43ca51d213ee Mon Sep 17 00:00:00 2001 From: Don HO Date: Sun, 11 Apr 2021 19:59:30 +0200 Subject: [PATCH] Add padding options in the edit zonze Fix #2323 --- PowerEditor/installer/nativeLang/english.xml | 4 ++ PowerEditor/installer/nativeLang/french.xml | 4 ++ .../nativeLang/taiwaneseMandarin.xml | 4 ++ PowerEditor/src/Notepad_plus.cpp | 71 +++++++++---------- PowerEditor/src/Notepad_plus.h | 2 +- PowerEditor/src/NppBigSwitch.cpp | 19 +++++ PowerEditor/src/NppCommands.cpp | 4 +- PowerEditor/src/Parameters.cpp | 8 +-- PowerEditor/src/Parameters.h | 11 ++- .../ScintillaComponent/ScintillaEditView.cpp | 13 ++++ .../ScintillaComponent/ScintillaEditView.h | 2 + .../WinControls/DocumentMap/documentMap.cpp | 29 ++++---- .../src/WinControls/DocumentMap/documentMap.h | 1 - .../DocumentMap/documentSnapshot.cpp | 17 ++++- .../DocumentMap/documentSnapshot.h | 2 +- .../src/WinControls/Preference/preference.rc | 20 ++++-- .../WinControls/Preference/preferenceDlg.cpp | 54 +++++++++++++- .../WinControls/Preference/preference_rc.h | 15 ++-- PowerEditor/src/resource.h | 1 + 19 files changed, 203 insertions(+), 78 deletions(-) diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 523ecf830..f8ff3f6d9 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -865,6 +865,10 @@ The comments are here for explanation, it's not necessary to translate them. You can define several column markers by using white space to separate the different numbers."/> + + + + diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml index 4001a2adb..b021f3a46 100644 --- a/PowerEditor/installer/nativeLang/french.xml +++ b/PowerEditor/installer/nativeLang/french.xml @@ -822,6 +822,10 @@ Vous pouvez définir plusieurs marqueurs de colonne en utilisant un espace pour + + + + diff --git a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml index fe317568d..5f68323d3 100644 --- a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml +++ b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml @@ -829,6 +829,10 @@ 使用空格分隔不同數字來定義多個列標記。"/> + + + + diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 1bf0807f2..c09d0aa18 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -219,7 +219,7 @@ LRESULT Notepad_plus::init(HWND hwnd) _mainWindowStatus = WindowMainActive; _activeView = MAIN_VIEW; - const ScintillaViewParams & svp1 = nppParam.getSVP(); + const ScintillaViewParams & svp = nppParam.getSVP(); int tabBarStatus = nppGUI._tabStatus; @@ -243,13 +243,13 @@ LRESULT Notepad_plus::init(HWND hwnd) _invisibleEditView.wrap(false); // Make sure no slow down // Configuration of 2 scintilla views - _mainEditView.showMargin(ScintillaEditView::_SC_MARGE_LINENUMBER, svp1._lineNumberMarginShow); - _subEditView.showMargin(ScintillaEditView::_SC_MARGE_LINENUMBER, svp1._lineNumberMarginShow); - _mainEditView.showMargin(ScintillaEditView::_SC_MARGE_SYBOLE, svp1._bookMarkMarginShow); - _subEditView.showMargin(ScintillaEditView::_SC_MARGE_SYBOLE, svp1._bookMarkMarginShow); + _mainEditView.showMargin(ScintillaEditView::_SC_MARGE_LINENUMBER, svp._lineNumberMarginShow); + _subEditView.showMargin(ScintillaEditView::_SC_MARGE_LINENUMBER, svp._lineNumberMarginShow); + _mainEditView.showMargin(ScintillaEditView::_SC_MARGE_SYBOLE, svp._bookMarkMarginShow); + _subEditView.showMargin(ScintillaEditView::_SC_MARGE_SYBOLE, svp._bookMarkMarginShow); - _mainEditView.showIndentGuideLine(svp1._indentGuideLineShow); - _subEditView.showIndentGuideLine(svp1._indentGuideLineShow); + _mainEditView.showIndentGuideLine(svp._indentGuideLineShow); + _subEditView.showIndentGuideLine(svp._indentGuideLineShow); ::SendMessage(hwnd, NPPM_INTERNAL_SETCARETWIDTH, 0, 0); ::SendMessage(hwnd, NPPM_INTERNAL_SETCARETBLINKRATE, 0, 0); @@ -259,53 +259,53 @@ LRESULT Notepad_plus::init(HWND hwnd) _pluginsAdminDlg.init(_pPublicInterface->getHinst(), hwnd); //Marker Margin config - _mainEditView.setMakerStyle(svp1._folderStyle); - _subEditView.setMakerStyle(svp1._folderStyle); + _mainEditView.setMakerStyle(svp._folderStyle); + _subEditView.setMakerStyle(svp._folderStyle); _mainEditView.defineDocType(_mainEditView.getCurrentBuffer()->getLangType()); _subEditView.defineDocType(_subEditView.getCurrentBuffer()->getLangType()); //Line wrap method - _mainEditView.setWrapMode(svp1._lineWrapMethod); - _subEditView.setWrapMode(svp1._lineWrapMethod); + _mainEditView.setWrapMode(svp._lineWrapMethod); + _subEditView.setWrapMode(svp._lineWrapMethod); - _mainEditView.execute(SCI_SETCARETLINEVISIBLE, svp1._currentLineHilitingShow); - _subEditView.execute(SCI_SETCARETLINEVISIBLE, svp1._currentLineHilitingShow); + _mainEditView.execute(SCI_SETCARETLINEVISIBLE, svp._currentLineHilitingShow); + _subEditView.execute(SCI_SETCARETLINEVISIBLE, svp._currentLineHilitingShow); - _mainEditView.execute(SCI_SETENDATLASTLINE, !svp1._scrollBeyondLastLine); - _subEditView.execute(SCI_SETENDATLASTLINE, !svp1._scrollBeyondLastLine); + _mainEditView.execute(SCI_SETENDATLASTLINE, !svp._scrollBeyondLastLine); + _subEditView.execute(SCI_SETENDATLASTLINE, !svp._scrollBeyondLastLine); - if (svp1._doSmoothFont) + if (svp._doSmoothFont) { _mainEditView.execute(SCI_SETFONTQUALITY, SC_EFF_QUALITY_LCD_OPTIMIZED); _subEditView.execute(SCI_SETFONTQUALITY, SC_EFF_QUALITY_LCD_OPTIMIZED); } - _mainEditView.setBorderEdge(svp1._showBorderEdge); - _subEditView.setBorderEdge(svp1._showBorderEdge); + _mainEditView.setBorderEdge(svp._showBorderEdge); + _subEditView.setBorderEdge(svp._showBorderEdge); _mainEditView.execute(SCI_SETCARETLINEVISIBLEALWAYS, true); _subEditView.execute(SCI_SETCARETLINEVISIBLEALWAYS, true); - _mainEditView.wrap(svp1._doWrap); - _subEditView.wrap(svp1._doWrap); + _mainEditView.wrap(svp._doWrap); + _subEditView.wrap(svp._doWrap); ::SendMessage(hwnd, NPPM_INTERNAL_EDGEMULTISETSIZE, 0, 0); - _mainEditView.showEOL(svp1._eolShow); - _subEditView.showEOL(svp1._eolShow); + _mainEditView.showEOL(svp._eolShow); + _subEditView.showEOL(svp._eolShow); - _mainEditView.showWSAndTab(svp1._whiteSpaceShow); - _subEditView.showWSAndTab(svp1._whiteSpaceShow); + _mainEditView.showWSAndTab(svp._whiteSpaceShow); + _subEditView.showWSAndTab(svp._whiteSpaceShow); - _mainEditView.showWrapSymbol(svp1._wrapSymbolShow); - _subEditView.showWrapSymbol(svp1._wrapSymbolShow); + _mainEditView.showWrapSymbol(svp._wrapSymbolShow); + _subEditView.showWrapSymbol(svp._wrapSymbolShow); _mainEditView.performGlobalStyles(); _subEditView.performGlobalStyles(); _zoomOriginalValue = static_cast(_pEditView->execute(SCI_GETZOOM)); - _mainEditView.execute(SCI_SETZOOM, svp1._zoom); - _subEditView.execute(SCI_SETZOOM, svp1._zoom2); + _mainEditView.execute(SCI_SETZOOM, svp._zoom); + _subEditView.execute(SCI_SETZOOM, svp._zoom2); ::SendMessage(hwnd, NPPM_INTERNAL_SETMULTISELCTION, 0, 0); @@ -329,6 +329,12 @@ LRESULT Notepad_plus::init(HWND hwnd) _mainEditView.execute(SCI_SETAUTOMATICFOLD, SC_AUTOMATICFOLD_SHOW); _subEditView.execute(SCI_SETAUTOMATICFOLD, SC_AUTOMATICFOLD_SHOW); + // Set padding info + _mainEditView.execute(SCI_SETMARGINLEFT, 0, svp._paddingLeft); + _mainEditView.execute(SCI_SETMARGINRIGHT, 0, svp._paddingRight); + _subEditView.execute(SCI_SETMARGINLEFT, 0, svp._paddingLeft); + _subEditView.execute(SCI_SETMARGINRIGHT, 0, svp._paddingRight); + TabBarPlus::doDragNDrop(true); if (_toReduceTabBar) @@ -5474,14 +5480,7 @@ void Notepad_plus::distractionFreeToggle() else { // enable it - const int defaultDiviser = 4; - int diviser = svp._distractionFreeDivPart > 2 ? svp._distractionFreeDivPart : defaultDiviser; - int w = _pEditView->getWidth(); - int paddingLen = w / diviser; - if (paddingLen <= 0) - paddingLen = w / defaultDiviser; - - paddingLeft = paddingRight = paddingLen; + paddingLeft = paddingRight = svp.getDistractionFreePadding(_pEditView->getWidth());; _restoreButton.setButtonStatus(buttonStatus_distractionFree); } diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index 5da1a6784..890547463 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -333,7 +333,7 @@ private: // make sure we don't recursively call doClose when closing the last file with -quitOnEmpty bool _isAttemptingCloseOnQuit = false; - // For FullScreen/PostIt features + // For FullScreen/PostIt/DistractionFree features VisibleGUIConf _beforeSpecialView; void fullScreenToggle(); void postItToggle(); diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 57a51935c..e35204113 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -2542,6 +2542,25 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa } } + case NPPM_INTERNAL_UPDATETEXTZONEPADDING: + { + ScintillaViewParams &svp = const_cast(nppParam.getSVP()); + if (_beforeSpecialView._isDistractionFree) + { + int paddingLen = svp.getDistractionFreePadding(_pEditView->getWidth()); + _pEditView->execute(SCI_SETMARGINLEFT, 0, paddingLen); + _pEditView->execute(SCI_SETMARGINRIGHT, 0, paddingLen); + } + else + { + _mainEditView.execute(SCI_SETMARGINLEFT, 0, svp._paddingLeft); + _mainEditView.execute(SCI_SETMARGINRIGHT, 0, svp._paddingRight); + _subEditView.execute(SCI_SETMARGINLEFT, 0, svp._paddingLeft); + _subEditView.execute(SCI_SETMARGINRIGHT, 0, svp._paddingRight); + } + return TRUE; + } + default: { if (message == WDN_NOTIFY) diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 4db380a5c..4366f911d 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -2027,8 +2027,8 @@ void Notepad_plus::command(int id) case IDM_VIEW_DISTRACTIONFREE: { - if (((_beforeSpecialView._isDistractionFree && _beforeSpecialView._isFullScreen && _beforeSpecialView._isPostIt)) || - ((!_beforeSpecialView._isDistractionFree && !_beforeSpecialView._isFullScreen && !_beforeSpecialView._isPostIt))) + if ((_beforeSpecialView._isDistractionFree && _beforeSpecialView._isFullScreen && _beforeSpecialView._isPostIt) || + (!_beforeSpecialView._isDistractionFree && !_beforeSpecialView._isFullScreen && !_beforeSpecialView._isPostIt)) distractionFreeToggle(); } break; diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 2abf782d3..92b4aeda6 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -5533,22 +5533,22 @@ void NppParameters::feedScintillaParam(TiXmlNode *node) nm = element->Attribute(TEXT("paddingLeft"), &val); if (nm) { - if (val >= 0 && val <= 9) + if (val >= 0 && val <= 30) _svp._paddingLeft = static_cast(val); } nm = element->Attribute(TEXT("paddingRight"), &val); if (nm) { - if (val >= 0 && val <= 9) + if (val >= 0 && val <= 30) _svp._paddingRight = static_cast(val); } nm = element->Attribute(TEXT("distractionFreeDivPart"), &val); if (nm) { - if (val >= 3 && val <= 255) - _svp._borderWidth = static_cast(val); + if (val >= 3 && val <= 9) + _svp._distractionFreeDivPart = static_cast(val); } } diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 7446b1bac..8b0b325f0 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -941,7 +941,16 @@ struct ScintillaViewParams // distractionFreeDivPart is used for divising the fullscreen pixel width. // the result of division will be the left & right padding in Distraction Free mode - unsigned char _distractionFreeDivPart = 4; // 3-255 parts + unsigned char _distractionFreeDivPart = 4; // 3-9 parts + + int getDistractionFreePadding(int editViewWidth) const { + const int defaultDiviser = 4; + int diviser = _distractionFreeDivPart > 2 ? _distractionFreeDivPart : defaultDiviser; + int paddingLen = editViewWidth / diviser; + if (paddingLen <= 0) + paddingLen = editViewWidth / defaultDiviser; + return paddingLen; + }; }; const int NB_LIST = 20; diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp index ae6c23edc..0c18d62d1 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp @@ -3755,6 +3755,19 @@ void ScintillaEditView::getFoldColor(COLORREF& fgColor, COLORREF& bgColor, COLOR } } +int ScintillaEditView::getTextZoneWidth() const +{ + RECT editorRect; + getClientRect(editorRect); + + int marginWidths = 0; + for (int m = 0; m < 4; ++m) + { + marginWidths += static_cast(execute(SCI_GETMARGINWIDTHN, m)); + } + return editorRect.right - editorRect.left - marginWidths; +} + pair ScintillaEditView::getSelectedCharsAndLinesCount(int maxSelectionsForLineCount /* = -1 */) const { pair selectedCharsAndLines(0, 0); diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.h b/PowerEditor/src/ScintillaComponent/ScintillaEditView.h index 965e4d001..c92ebbb1d 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.h @@ -429,6 +429,8 @@ public: return long(execute(SCI_TEXTHEIGHT)); }; + int getTextZoneWidth() const; + void gotoLine(int line){ if (line < execute(SCI_GETLINECOUNT)) execute(SCI_GOTOLINE,line); diff --git a/PowerEditor/src/WinControls/DocumentMap/documentMap.cpp b/PowerEditor/src/WinControls/DocumentMap/documentMap.cpp index 1556d9c38..27167c74c 100644 --- a/PowerEditor/src/WinControls/DocumentMap/documentMap.cpp +++ b/PowerEditor/src/WinControls/DocumentMap/documentMap.cpp @@ -86,7 +86,7 @@ bool DocumentMap::needToRecomputeWith(const ScintillaEditView *editView) if (_displayZoom != currentZoom) return true; - int currentTextZoneWidth = getEditorTextZoneWidth(editView); + int currentTextZoneWidth = pEditView->getTextZoneWidth(); if (_displayWidth != currentTextZoneWidth) return true; @@ -163,7 +163,7 @@ void DocumentMap::wrapMap(const ScintillaEditView *editView) if (pEditView->isWrap()) { // get current scintilla width W1 - int editZoneWidth = getEditorTextZoneWidth(editView); + int editZoneWidth = pEditView->getTextZoneWidth(); // update the wrap needed data _displayWidth = editZoneWidth; @@ -179,23 +179,18 @@ void DocumentMap::wrapMap(const ScintillaEditView *editView) // sync wrapping indent mode _pMapView->execute(SCI_SETWRAPINDENTMODE, pEditView->execute(SCI_GETWRAPINDENTMODE)); - } - doMove(); -} - -int DocumentMap::getEditorTextZoneWidth(const ScintillaEditView *editView) -{ - const ScintillaEditView *pEditView = editView ? editView : *_ppEditView; + const ScintillaViewParams& svp = NppParameters::getInstance().getSVP(); - RECT editorRect; - pEditView->getClientRect(editorRect); - - int marginWidths = 0; - for (int m = 0; m < 4; ++m) - { - marginWidths += static_cast(pEditView->execute(SCI_GETMARGINWIDTHN, m)); + if (svp._paddingLeft || svp._paddingRight) + { + int paddingMapLeft = static_cast(svp._paddingLeft / (editZoneWidth / docMapWidth)); + int paddingMapRight = static_cast(svp._paddingRight / (editZoneWidth / docMapWidth)); + _pMapView->execute(SCI_SETMARGINLEFT, 0, paddingMapLeft); + _pMapView->execute(SCI_SETMARGINRIGHT, 0, paddingMapRight); + } } - return editorRect.right - editorRect.left - marginWidths; + + doMove(); } void DocumentMap::scrollMap() diff --git a/PowerEditor/src/WinControls/DocumentMap/documentMap.h b/PowerEditor/src/WinControls/DocumentMap/documentMap.h index 8346cf8a2..fc87ffc43 100644 --- a/PowerEditor/src/WinControls/DocumentMap/documentMap.h +++ b/PowerEditor/src/WinControls/DocumentMap/documentMap.h @@ -127,7 +127,6 @@ public: protected: virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); bool needToRecomputeWith(const ScintillaEditView *editView = nullptr); - int getEditorTextZoneWidth(const ScintillaEditView *editView = nullptr); private: ScintillaEditView **_ppEditView = nullptr; diff --git a/PowerEditor/src/WinControls/DocumentMap/documentSnapshot.cpp b/PowerEditor/src/WinControls/DocumentMap/documentSnapshot.cpp index 0f271b15c..93d6c98d5 100644 --- a/PowerEditor/src/WinControls/DocumentMap/documentSnapshot.cpp +++ b/PowerEditor/src/WinControls/DocumentMap/documentSnapshot.cpp @@ -77,7 +77,7 @@ void DocumentPeeker::syncDisplay(Buffer *buf, ScintillaEditView & scintSource) MapPosition mp = buf->getMapPosition(); if (mp.isValid() && mp.canScroll()) { - scrollSnapshotWith(mp); + scrollSnapshotWith(mp, scintSource.getTextZoneWidth()); } Buffer *buf = _pPeekerView->getCurrentBuffer(); @@ -94,7 +94,7 @@ void DocumentPeeker::syncDisplay(Buffer *buf, ScintillaEditView & scintSource) } -void DocumentPeeker::scrollSnapshotWith(const MapPosition & mapPos) +void DocumentPeeker::scrollSnapshotWith(const MapPosition & mapPos, int textZoneWidth) { if (_pPeekerView) { @@ -120,6 +120,19 @@ void DocumentPeeker::scrollSnapshotWith(const MapPosition & mapPos) _pPeekerView->wrap(mapPos._isWrap); _pPeekerView->execute(SCI_SETWRAPINDENTMODE, mapPos._wrapIndentMode); + // + // Add padding + // + const ScintillaViewParams& svp = NppParameters::getInstance().getSVP(); + if (svp._paddingLeft || svp._paddingRight) + { + int docPeekerWidth = _pPeekerView->getTextZoneWidth(); + int paddingMapLeft = static_cast(svp._paddingLeft / (textZoneWidth / docPeekerWidth)); + int paddingMapRight = static_cast(svp._paddingRight / (textZoneWidth / docPeekerWidth)); + _pPeekerView->execute(SCI_SETMARGINLEFT, 0, paddingMapLeft); + _pPeekerView->execute(SCI_SETMARGINRIGHT, 0, paddingMapRight); + } + // // Reset to zero // diff --git a/PowerEditor/src/WinControls/DocumentMap/documentSnapshot.h b/PowerEditor/src/WinControls/DocumentMap/documentSnapshot.h index 0f10d6696..32290a7d5 100644 --- a/PowerEditor/src/WinControls/DocumentMap/documentSnapshot.h +++ b/PowerEditor/src/WinControls/DocumentMap/documentSnapshot.h @@ -40,7 +40,7 @@ public: _hParent = parent2set; }; - void scrollSnapshotWith(const MapPosition & mapPos); + void scrollSnapshotWith(const MapPosition & mapPos, int textZoneWidth); void saveCurrentSnapshot(ScintillaEditView & editView); protected: diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index 0d52aee0f..d4631cdbf 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -100,19 +100,29 @@ BEGIN CONTROL "Circle tree",IDC_RADIO_CIRCLE,"Button",BS_AUTORADIOBUTTON,31,63,62,10 CONTROL "None",IDC_RADIO_FOLDMARGENONE,"Button",BS_AUTORADIOBUTTON,31,92,61,10 CONTROL "Box tree",IDC_RADIO_BOX,"Button",BS_AUTORADIOBUTTON,31,77,61,10 - GROUPBOX "Vertical Edge Settings",IDC_VES_GB_STATIC,116,21,148,135,BS_CENTER + GROUPBOX "Vertical Edge Settings",IDC_VES_GB_STATIC,116,21,148,136,BS_CENTER LTEXT "Add your column marker by indicating its position with a decimal number.\nYou can define several column markers by using white space to separate the different numbers.",IDC_STATIC_MULTILNMODE_TIP,124,36,134,55 EDITTEXT IDC_COLUMNPOS_EDIT,126,93,125,36,ES_MULTILINE CONTROL "Background mode",IDC_CHECK_EDGEBGMODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,127,138,122,10 - GROUPBOX "Border Width",IDC_BORDERWIDTH_STATIC,21,112,85,45,BS_CENTER + GROUPBOX "Border Width",IDC_BORDERWIDTH_STATIC,22,112,83,45,BS_CENTER CONTROL "",IDC_BORDERWIDTH_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,24,125,67,13 - LTEXT "0",IDC_BORDERWIDTHVAL_STATIC,92,125,12,8 + LTEXT "0",IDC_BORDERWIDTHVAL_STATIC,92,126,12,8 CONTROL "No edge",IDC_CHECK_NOEDGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,29,142,60,10 - GROUPBOX "Line Number",IDC_LINENUMBERMARGE_GB_STATIC,275,21,135,66,BS_CENTER + GROUPBOX "Line Number",IDC_LINENUMBERMARGE_GB_STATIC,274,21,135,66,BS_CENTER CONTROL "Display",IDC_CHECK_LINENUMBERMARGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,281,35,85,10 CONTROL "Dynamic width",IDC_RADIO_DYNAMIC,"Button",BS_AUTORADIOBUTTON | WS_GROUP,293,51,110,10 CONTROL "Constant width",IDC_RADIO_CONSTANT,"Button",BS_AUTORADIOBUTTON,293,65,108,10 - CONTROL "Display bookmark",IDC_CHECK_BOOKMARKMARGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,281,97,150,10 + CONTROL "Display bookmark",IDC_CHECK_BOOKMARKMARGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,281,163,150,10 + GROUPBOX "Padding",IDC_PADDING_STATIC,274,94,135,63,BS_CENTER + RTEXT "Left",IDC_PADDINGLEFT_STATIC,280,108,45,8 + CONTROL "",IDC_PADDINGLEFT_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,328,107,67,13 + LTEXT "0",IDC_PADDINGLEFTVAL_STATIC,396,108,12,8 + RTEXT "Right",IDC_PADDINGRIGHT_STATIC,282,124,43,8 + CONTROL "",IDC_PADDINGRIGHT_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,328,123,67,13 + LTEXT "0",IDC_PADDINGRIGHTVAL_STATIC,396,124,12,8 + RTEXT "Distraction Free",IDC_DISTRACTIONFREE_STATIC,275,140,72,8 + CONTROL "",IDC_DISTRACTIONFREE_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,348,139,47,13 + LTEXT "0",IDC_DISTRACTIONFREEVAL_STATIC,396,140,12,8 END diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 070839ec2..60d6cfa0a 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -34,6 +34,14 @@ const int BORDERWIDTH_SMALLEST = 0; const int BORDERWIDTH_LARGEST = 30; const int BORDERWIDTH_INTERVAL = 1; +const int PADDING_SMALLEST = 0; +const int PADDING_LARGEST = 30; +const int PADDING_INTERVAL = 1; + +const int DISTRACTIONFREE_SMALLEST = 3; +const int DISTRACTIONFREE_LARGEST = 9; +const int DISTRACTIONFREE_INTERVAL = 1; + // This int encoding array is built from "EncodingUnit encodings[]" (see EncodingMapper.cpp) // And NewDocumentSubDlg will use "int encoding array" to get more info from "EncodingUnit encodings[]" static int encodings[] = { @@ -814,14 +822,32 @@ INT_PTR CALLBACK MarginsBorderEdgeSubDlg::run_dlgProc(UINT message, WPARAM wPara switch (message) { case WM_INITDIALOG : - { + { + const ScintillaViewParams & svp = nppParam.getSVP(); ::SendMessage(::GetDlgItem(_hSelf, IDC_BORDERWIDTH_SLIDER),TBM_SETRANGEMIN, TRUE, BORDERWIDTH_SMALLEST); ::SendMessage(::GetDlgItem(_hSelf, IDC_BORDERWIDTH_SLIDER),TBM_SETRANGEMAX, TRUE, BORDERWIDTH_LARGEST); ::SendMessage(::GetDlgItem(_hSelf, IDC_BORDERWIDTH_SLIDER),TBM_SETPAGESIZE, 0, BORDERWIDTH_INTERVAL); - const ScintillaViewParams & svp = nppParam.getSVP(); ::SendMessage(::GetDlgItem(_hSelf, IDC_BORDERWIDTH_SLIDER),TBM_SETPOS, TRUE, svp._borderWidth); ::SetDlgItemInt(_hSelf, IDC_BORDERWIDTHVAL_STATIC, svp._borderWidth, FALSE); + ::SendMessage(::GetDlgItem(_hSelf, IDC_PADDINGLEFT_SLIDER), TBM_SETRANGEMIN, TRUE, PADDING_SMALLEST); + ::SendMessage(::GetDlgItem(_hSelf, IDC_PADDINGLEFT_SLIDER), TBM_SETRANGEMAX, TRUE, PADDING_LARGEST); + ::SendMessage(::GetDlgItem(_hSelf, IDC_PADDINGLEFT_SLIDER), TBM_SETPAGESIZE, 0, PADDING_INTERVAL); + ::SendMessage(::GetDlgItem(_hSelf, IDC_PADDINGLEFT_SLIDER), TBM_SETPOS, TRUE, svp._paddingLeft); + ::SetDlgItemInt(_hSelf, IDC_PADDINGLEFTVAL_STATIC, svp._paddingLeft, FALSE); + + ::SendMessage(::GetDlgItem(_hSelf, IDC_PADDINGRIGHT_SLIDER), TBM_SETRANGEMIN, TRUE, PADDING_SMALLEST); + ::SendMessage(::GetDlgItem(_hSelf, IDC_PADDINGRIGHT_SLIDER), TBM_SETRANGEMAX, TRUE, PADDING_LARGEST); + ::SendMessage(::GetDlgItem(_hSelf, IDC_PADDINGRIGHT_SLIDER), TBM_SETPAGESIZE, 0, PADDING_INTERVAL); + ::SendMessage(::GetDlgItem(_hSelf, IDC_PADDINGRIGHT_SLIDER), TBM_SETPOS, TRUE, svp._paddingRight); + ::SetDlgItemInt(_hSelf, IDC_PADDINGRIGHTVAL_STATIC, svp._paddingRight, FALSE); + + ::SendMessage(::GetDlgItem(_hSelf, IDC_DISTRACTIONFREE_SLIDER), TBM_SETRANGEMIN, TRUE, DISTRACTIONFREE_SMALLEST); + ::SendMessage(::GetDlgItem(_hSelf, IDC_DISTRACTIONFREE_SLIDER), TBM_SETRANGEMAX, TRUE, DISTRACTIONFREE_LARGEST); + ::SendMessage(::GetDlgItem(_hSelf, IDC_DISTRACTIONFREE_SLIDER), TBM_SETPAGESIZE, 0, DISTRACTIONFREE_INTERVAL); + ::SendMessage(::GetDlgItem(_hSelf, IDC_DISTRACTIONFREE_SLIDER), TBM_SETPOS, TRUE, svp._distractionFreeDivPart); + ::SetDlgItemInt(_hSelf, IDC_DISTRACTIONFREEVAL_STATIC, svp._distractionFreeDivPart, FALSE); + initScintParam(); ETDTProc enableDlgTheme = (ETDTProc)nppParam.getEnableThemeDlgTexture(); @@ -832,15 +858,37 @@ INT_PTR CALLBACK MarginsBorderEdgeSubDlg::run_dlgProc(UINT message, WPARAM wPara case WM_HSCROLL: { + ScintillaViewParams & svp = (ScintillaViewParams &)nppParam.getSVP(); HWND hBorderWidthSlider = ::GetDlgItem(_hSelf, IDC_BORDERWIDTH_SLIDER); + HWND hPaddingLeftSlider = ::GetDlgItem(_hSelf, IDC_PADDINGLEFT_SLIDER); + HWND hPaddingRightSlider = ::GetDlgItem(_hSelf, IDC_PADDINGRIGHT_SLIDER); + HWND hDistractionFreeSlider = ::GetDlgItem(_hSelf, IDC_DISTRACTIONFREE_SLIDER); if (reinterpret_cast(lParam) == hBorderWidthSlider) { auto borderWidth = ::SendMessage(hBorderWidthSlider, TBM_GETPOS, 0, 0); - ScintillaViewParams & svp = (ScintillaViewParams &)nppParam.getSVP(); svp._borderWidth = static_cast(borderWidth); ::SetDlgItemInt(_hSelf, IDC_BORDERWIDTHVAL_STATIC, static_cast(borderWidth), FALSE); ::SendMessage(::GetParent(_hParent), WM_SIZE, 0, 0); } + else if (reinterpret_cast(lParam) == hPaddingLeftSlider) + { + svp._paddingLeft = static_cast(::SendMessage(hPaddingLeftSlider, TBM_GETPOS, 0, 0)); + ::SetDlgItemInt(_hSelf, IDC_PADDINGLEFTVAL_STATIC, static_cast(svp._paddingLeft), FALSE); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_UPDATETEXTZONEPADDING, 0, 0); + + } + else if (reinterpret_cast(lParam) == hPaddingRightSlider) + { + svp._paddingRight = static_cast(::SendMessage(hPaddingRightSlider, TBM_GETPOS, 0, 0)); + ::SetDlgItemInt(_hSelf, IDC_PADDINGRIGHTVAL_STATIC, static_cast(svp._paddingRight), FALSE); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_UPDATETEXTZONEPADDING, 0, 0); + } + else if (reinterpret_cast(lParam) == hDistractionFreeSlider) + { + svp._distractionFreeDivPart = static_cast(::SendMessage(hDistractionFreeSlider, TBM_GETPOS, 0, 0)); + ::SetDlgItemInt(_hSelf, IDC_DISTRACTIONFREEVAL_STATIC, static_cast(svp._distractionFreeDivPart), FALSE); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_UPDATETEXTZONEPADDING, 0, 0); + } return 0; //return zero when handled } diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index 1e3350d11..3df46e4eb 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -78,12 +78,12 @@ #define IDC_CHECK_LINENUMBERMARGE (IDD_PREFERENCE_SUB_EDITING + 6) #define IDC_CHECK_BOOKMARKMARGE (IDD_PREFERENCE_SUB_EDITING + 7) - //#define IDC_CHECK_SHOWVERTICALEDGE (IDD_PREFERENCE_SUB_EDITING + 8) - //#define IDC_NBCOLONE_STATIC (IDD_PREFERENCE_SUB_EDITING + 9) - //#define IDC_COLONENUMBER_STATIC (IDD_PREFERENCE_SUB_EDITING + 10) + #define IDC_PADDING_STATIC (IDD_PREFERENCE_SUB_EDITING + 8) + #define IDC_PADDINGLEFT_STATIC (IDD_PREFERENCE_SUB_EDITING + 9) + #define IDC_PADDINGRIGHT_STATIC (IDD_PREFERENCE_SUB_EDITING + 10) #define IDC_VES_GB_STATIC (IDD_PREFERENCE_SUB_EDITING + 11) - //#define IDC_RADIO_LNMODE (IDD_PREFERENCE_SUB_EDITING + 12) + #define IDC_DISTRACTIONFREE_STATIC (IDD_PREFERENCE_SUB_EDITING + 12) #define IDC_CHECK_EDGEBGMODE (IDD_PREFERENCE_SUB_EDITING + 13) #define IDC_CHECK_CURRENTLINEHILITE (IDD_PREFERENCE_SUB_EDITING + 14) #define IDC_CHECK_SMOOTHFONT (IDD_PREFERENCE_SUB_EDITING + 15) @@ -96,7 +96,7 @@ #define IDC_CARETBLINKRATE_F_STATIC (IDD_PREFERENCE_SUB_EDITING + 21) #define IDC_CARETBLINKRATE_S_STATIC (IDD_PREFERENCE_SUB_EDITING + 22) #define IDC_CHECK_DOCCHANGESTATEMARGE (IDD_PREFERENCE_SUB_EDITING + 23) - //#define IDC_MULTISELECTION_GB_STATIC (IDD_PREFERENCE_SUB_EDITING + 24) + #define IDC_DISTRACTIONFREE_SLIDER (IDD_PREFERENCE_SUB_EDITING + 24) #define IDC_CHECK_MULTISELECTION (IDD_PREFERENCE_SUB_EDITING + 25) #define IDC_RADIO_FOLDMARGENONE (IDD_PREFERENCE_SUB_EDITING + 26) @@ -116,6 +116,11 @@ #define IDC_STATIC_MULTILNMODE_TIP (IDD_PREFERENCE_SUB_EDITING + 37) #define IDC_COLUMNPOS_EDIT (IDD_PREFERENCE_SUB_EDITING + 38) #define IDC_CHECK_RIGHTCLICKKEEPSSELECTION (IDD_PREFERENCE_SUB_EDITING + 39) + #define IDC_PADDINGLEFT_SLIDER (IDD_PREFERENCE_SUB_EDITING + 40) + #define IDC_PADDINGRIGHT_SLIDER (IDD_PREFERENCE_SUB_EDITING + 41) + #define IDC_PADDINGLEFTVAL_STATIC (IDD_PREFERENCE_SUB_EDITING + 42) + #define IDC_PADDINGRIGHTVAL_STATIC (IDD_PREFERENCE_SUB_EDITING + 43) + #define IDC_DISTRACTIONFREEVAL_STATIC (IDD_PREFERENCE_SUB_EDITING + 44) #define IDD_PREFERENCE_SUB_DELIMITER 6250 //(IDD_PREFERENCE_BOX + 250) #define IDC_DELIMITERSETTINGS_GB_STATIC (IDD_PREFERENCE_SUB_DELIMITER + 1) diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index be151353b..b803f3171 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -445,6 +445,7 @@ #define NPPM_INTERNAL_SCINTILLAFINDERCOPYVERBATIM (NOTEPADPLUS_USER_INTERNAL + 55) #define NPPM_INTERNAL_FINDINPROJECTS (NOTEPADPLUS_USER_INTERNAL + 56) #define NPPM_INTERNAL_SCINTILLAFINDERPURGE (NOTEPADPLUS_USER_INTERNAL + 57) + #define NPPM_INTERNAL_UPDATETEXTZONEPADDING (NOTEPADPLUS_USER_INTERNAL + 58) // See Notepad_plus_msgs.h //#define NOTEPADPLUS_USER (WM_USER + 1000)