From 8bf11be0b581f919d9918c055507a6e497c42f7f Mon Sep 17 00:00:00 2001 From: ozone10 Date: Wed, 21 Jul 2021 22:00:08 +0200 Subject: [PATCH] Restore edit zone border in dark mode Restore functionality for option No edge in preference when using dark mode. Fix #10205, close #10211 --- PowerEditor/src/Notepad_plus.cpp | 12 ++-------- PowerEditor/src/NppBigSwitch.cpp | 13 ++--------- .../ScintillaComponent/ScintillaEditView.cpp | 22 ++++++++++++++++--- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 57579cc70..d62403b61 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -284,16 +284,8 @@ LRESULT Notepad_plus::init(HWND hwnd) _subEditView.execute(SCI_SETFONTQUALITY, SC_EFF_QUALITY_LCD_OPTIMIZED); } - if (NppDarkMode::isEnabled()) - { - _mainEditView.setBorderEdge(false); - _subEditView.setBorderEdge(false); - } - else - { - _mainEditView.setBorderEdge(svp._showBorderEdge); - _subEditView.setBorderEdge(svp._showBorderEdge); - } + _mainEditView.setBorderEdge(svp._showBorderEdge); + _subEditView.setBorderEdge(svp._showBorderEdge); _mainEditView.execute(SCI_SETCARETLINEVISIBLEALWAYS, true); _subEditView.execute(SCI_SETCARETLINEVISIBLEALWAYS, true); diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index d5d0a3565..42c078e80 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -1511,16 +1511,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa case NPPM_SETEDITORBORDEREDGE: { bool withBorderEdge = (lParam == 1); - if (NppDarkMode::isEnabled()) - { - _mainEditView.setBorderEdge(false); - _subEditView.setBorderEdge(false); - } - else - { - _mainEditView.setBorderEdge(withBorderEdge); - _subEditView.setBorderEdge(withBorderEdge); - } + _mainEditView.setBorderEdge(withBorderEdge); + _subEditView.setBorderEdge(withBorderEdge); return TRUE; } @@ -2746,4 +2738,3 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa _pluginsManager.relayNppMessages(message, wParam, lParam); return result; } - diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp index c9cdf4e1e..079c813d2 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp @@ -3705,13 +3705,29 @@ generic_string ScintillaEditView::getEOLString() void ScintillaEditView::setBorderEdge(bool doWithBorderEdge) { + long style = static_cast(::GetWindowLongPtr(_hSelf, GWL_STYLE)); long exStyle = static_cast(::GetWindowLongPtr(_hSelf, GWL_EXSTYLE)); - if (doWithBorderEdge) - exStyle |= WS_EX_CLIENTEDGE; - else + if (NppDarkMode::isEnabled()) + { exStyle &= ~WS_EX_CLIENTEDGE; + if (doWithBorderEdge) + style |= WS_BORDER; + else + style &= ~WS_BORDER; + } + else + { + style &= ~WS_BORDER; + + if (doWithBorderEdge) + exStyle |= WS_EX_CLIENTEDGE; + else + exStyle &= ~WS_EX_CLIENTEDGE; + } + + ::SetWindowLongPtr(_hSelf, GWL_STYLE, style); ::SetWindowLongPtr(_hSelf, GWL_EXSTYLE, exStyle); ::SetWindowPos(_hSelf, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); }