diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml
index f6ef49457..523ecf830 100644
--- a/PowerEditor/installer/nativeLang/english.xml
+++ b/PowerEditor/installer/nativeLang/english.xml
@@ -246,6 +246,7 @@ The comments are here for explanation, it's not necessary to translate them.
+
diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml
index 6aee03d10..4001a2adb 100644
--- a/PowerEditor/installer/nativeLang/french.xml
+++ b/PowerEditor/installer/nativeLang/french.xml
@@ -233,6 +233,7 @@
+
diff --git a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml
index aa103cb5e..fe317568d 100644
--- a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml
+++ b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml
@@ -228,6 +228,7 @@
+
diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp
index 12455a8c0..1bf0807f2 100644
--- a/PowerEditor/src/Notepad_plus.cpp
+++ b/PowerEditor/src/Notepad_plus.cpp
@@ -5338,10 +5338,9 @@ void Notepad_plus::fullScreenToggle()
void Notepad_plus::postItToggle()
{
- NppParameters& nppParam = NppParameters::getInstance();
if (!_beforeSpecialView._isPostIt) // PostIt disabled, enable it
{
- NppGUI & nppGUI = const_cast(nppParam.getNppGUI());
+ NppGUI & nppGUI = const_cast(NppParameters::getInstance().getNppGUI());
// get current status before switch to postIt
//check these always
{
@@ -5448,6 +5447,51 @@ void Notepad_plus::postItToggle()
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
}
+// Distraction Free mode uses full screen mode + post-it mode + setting padding on the both left & right sides.
+// In order to keep the coherence of data, when full screen mode or (and) post-it mode is (are) active,
+// Distraction Free mode should be innaccible, and vice versa.
+void Notepad_plus::distractionFreeToggle()
+{
+ // Toggle Distraction Free Mode
+ fullScreenToggle();
+ postItToggle();
+
+ // Get padding info
+ const ScintillaViewParams& svp = NppParameters::getInstance().getSVP();
+ int paddingLeft = 0;
+ int paddingRight = 0;
+
+ // Enable or disable Distraction Free Mode
+ if (_beforeSpecialView._isDistractionFree)
+ {
+ // disable it
+ paddingLeft = svp._paddingLeft;
+ paddingRight = svp._paddingRight;
+
+ _restoreButton.setButtonStatus(0);
+ _restoreButton.display(false);
+ }
+ 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;
+ _restoreButton.setButtonStatus(buttonStatus_distractionFree);
+ }
+
+ _beforeSpecialView._isDistractionFree = !_beforeSpecialView._isDistractionFree;
+
+ // set Distraction Free Mode paddin or restore the normal padding
+ _pEditView->execute(SCI_SETMARGINLEFT, 0, paddingLeft);
+ _pEditView->execute(SCI_SETMARGINRIGHT, 0, paddingRight);
+}
+
void Notepad_plus::doSynScorll(HWND whichView)
{
int column = 0;
diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h
index 03069e324..5da1a6784 100644
--- a/PowerEditor/src/Notepad_plus.h
+++ b/PowerEditor/src/Notepad_plus.h
@@ -82,8 +82,9 @@ struct VisibleGUIConf final
{
bool _isPostIt = false;
bool _isFullScreen = false;
+ bool _isDistractionFree = false;
- //Used by 2 modes
+ //Used by 3 modes
bool _isMenuShown = true;
DWORD_PTR _preStyle = (WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN);
@@ -336,6 +337,7 @@ private:
VisibleGUIConf _beforeSpecialView;
void fullScreenToggle();
void postItToggle();
+ void distractionFreeToggle();
// Keystroke macro recording and playback
Macro _macro;
diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc
index cd1eb7da7..24a9c8519 100644
--- a/PowerEditor/src/Notepad_plus.rc
+++ b/PowerEditor/src/Notepad_plus.rc
@@ -480,6 +480,7 @@ BEGIN
MENUITEM "Always on Top", IDM_VIEW_ALWAYSONTOP
MENUITEM "Toggle Full Screen Mode", IDM_VIEW_FULLSCREENTOGGLE
MENUITEM "Post-It", IDM_VIEW_POSTIT
+ MENUITEM "Distraction Free Mode", IDM_VIEW_DISTRACTIONFREE
MENUITEM SEPARATOR
POPUP "View Current File in"
diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp
index d02977b2c..4db380a5c 100644
--- a/PowerEditor/src/NppCommands.cpp
+++ b/PowerEditor/src/NppCommands.cpp
@@ -1835,10 +1835,6 @@ void Notepad_plus::command(int id)
inverseMarks();
break;
- case IDM_VIEW_FULLSCREENTOGGLE :
- fullScreenToggle();
- break;
-
case IDM_VIEW_ALWAYSONTOP:
{
int check = (::GetMenuState(_mainMenuHandle, id, MF_BYCOMMAND) == MF_CHECKED)?MF_UNCHECKED:MF_CHECKED;
@@ -2015,9 +2011,25 @@ void Notepad_plus::command(int id)
break;
}
+ case IDM_VIEW_FULLSCREENTOGGLE:
+ {
+ if (!_beforeSpecialView._isDistractionFree)
+ fullScreenToggle();
+ }
+ break;
+
case IDM_VIEW_POSTIT :
{
- postItToggle();
+ if (!_beforeSpecialView._isDistractionFree)
+ postItToggle();
+ }
+ break;
+
+ case IDM_VIEW_DISTRACTIONFREE:
+ {
+ 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 635a0a081..2abf782d3 100644
--- a/PowerEditor/src/Parameters.cpp
+++ b/PowerEditor/src/Parameters.cpp
@@ -238,6 +238,7 @@ static const WinMenuKeyDefinition winKeyDefs[] =
{ VK_NULL, IDM_VIEW_ALWAYSONTOP, false, false, false, nullptr },
{ VK_F11, IDM_VIEW_FULLSCREENTOGGLE, false, false, false, nullptr },
{ VK_F12, IDM_VIEW_POSTIT, false, false, false, nullptr },
+ { VK_NULL, IDM_VIEW_DISTRACTIONFREE, false, false, false, nullptr },
{ VK_NULL, IDM_VIEW_IN_FIREFOX, false, false, false, TEXT("View current file in Firefox") },
{ VK_NULL, IDM_VIEW_IN_CHROME, false, false, false, TEXT("View current file in Chrome") },
@@ -5528,6 +5529,27 @@ void NppParameters::feedScintillaParam(TiXmlNode *node)
else if (!lstrcmp(nm, TEXT("no")))
_svp._doSmoothFont = false;
}
+
+ nm = element->Attribute(TEXT("paddingLeft"), &val);
+ if (nm)
+ {
+ if (val >= 0 && val <= 9)
+ _svp._paddingLeft = static_cast(val);
+ }
+
+ nm = element->Attribute(TEXT("paddingRight"), &val);
+ if (nm)
+ {
+ if (val >= 0 && val <= 9)
+ _svp._paddingRight = static_cast(val);
+ }
+
+ nm = element->Attribute(TEXT("distractionFreeDivPart"), &val);
+ if (nm)
+ {
+ if (val >= 3 && val <= 255)
+ _svp._borderWidth = static_cast(val);
+ }
}
@@ -5781,6 +5803,9 @@ bool NppParameters::writeScintillaParams()
(scintNode->ToElement())->SetAttribute(TEXT("eolShow"), _svp._eolShow?TEXT("show"):TEXT("hide"));
(scintNode->ToElement())->SetAttribute(TEXT("borderWidth"), _svp._borderWidth);
(scintNode->ToElement())->SetAttribute(TEXT("smoothFont"), _svp._doSmoothFont ? TEXT("yes") : TEXT("no"));
+ (scintNode->ToElement())->SetAttribute(TEXT("paddingLeft"), _svp._paddingLeft);
+ (scintNode->ToElement())->SetAttribute(TEXT("paddingRight"), _svp._paddingRight);
+ (scintNode->ToElement())->SetAttribute(TEXT("distractionFreeDivPart"), _svp._distractionFreeDivPart);
return true;
}
diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h
index d0148809d..7446b1bac 100644
--- a/PowerEditor/src/Parameters.h
+++ b/PowerEditor/src/Parameters.h
@@ -935,6 +935,13 @@ struct ScintillaViewParams
bool _disableAdvancedScrolling = false;
bool _doSmoothFont = false;
bool _showBorderEdge = true;
+
+ unsigned char _paddingLeft = 0; // 0-9 pixel
+ unsigned char _paddingRight = 0; // 0-9 pixel
+
+ // 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
};
const int NB_LIST = 20;
diff --git a/PowerEditor/src/lesDlgs.cpp b/PowerEditor/src/lesDlgs.cpp
index eb00e4ce7..614449cfb 100644
--- a/PowerEditor/src/lesDlgs.cpp
+++ b/PowerEditor/src/lesDlgs.cpp
@@ -132,10 +132,16 @@ INT_PTR CALLBACK ButtonDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
case IDC_RESTORE_BUTTON :
{
int bs = getButtonStatus();
+
+ bool isDistractionFree = (bs & buttonStatus_distractionFree) != 0;
bool isFullScreen = (bs & buttonStatus_fullscreen) != 0;
bool isPostIt = (bs & buttonStatus_postit) != 0;
int cmd = 0;
- if (isFullScreen && isPostIt)
+ if (isDistractionFree)
+ {
+ cmd = IDM_VIEW_DISTRACTIONFREE;
+ }
+ else if (isFullScreen && isPostIt)
{
// remove postit firstly
cmd = IDM_VIEW_POSTIT;
diff --git a/PowerEditor/src/lesDlgs.h b/PowerEditor/src/lesDlgs.h
index 0a2a3f09d..5260a2e0d 100644
--- a/PowerEditor/src/lesDlgs.h
+++ b/PowerEditor/src/lesDlgs.h
@@ -44,12 +44,14 @@ private :
POINT _p = {0, 0};
};
-// 0 : sans fullscreen
+// 0 : normal window
// 1 : fullscreen
// 2 : postit
-const int buttonStatus_nada = 0;
-const int buttonStatus_fullscreen = 1;
-const int buttonStatus_postit = 2;
+// 4 : distractionFree
+const int buttonStatus_nada = 0; // 0000 0000
+const int buttonStatus_fullscreen = 1; // 0000 0001
+const int buttonStatus_postit = 2; // 0000 0010
+const int buttonStatus_distractionFree = 4; // 0000 0100
class ButtonDlg : public StaticDialog
{
diff --git a/PowerEditor/src/localization.cpp b/PowerEditor/src/localization.cpp
index f9c238f83..03bb600a7 100644
--- a/PowerEditor/src/localization.cpp
+++ b/PowerEditor/src/localization.cpp
@@ -63,14 +63,14 @@ MenuPosition menuPos[] = {
{ 2, 23, -1, "search-copyStyledText" },
{ 2, 25, -1, "search-bookmark" },
- { 3, 4, -1, "view-currentFileIn" },
- { 3, 6, -1, "view-showSymbol" },
- { 3, 7, -1, "view-zoom" },
- { 3, 8, -1, "view-moveCloneDocument" },
- { 3, 9, -1, "view-tab" },
- { 3, 18, -1, "view-collapseLevel" },
- { 3, 19, -1, "view-uncollapseLevel" },
- { 3, 23, -1, "view-project" },
+ { 3, 5, -1, "view-currentFileIn" },
+ { 3, 7, -1, "view-showSymbol" },
+ { 3, 8, -1, "view-zoom" },
+ { 3, 9, -1, "view-moveCloneDocument" },
+ { 3, 10, -1, "view-tab" },
+ { 3, 19, -1, "view-collapseLevel" },
+ { 3, 20, -1, "view-uncollapseLevel" },
+ { 3, 24, -1, "view-project" },
{ 4, 5, -1, "encoding-characterSets" },
{ 4, 5, 0, "encoding-arabic" },
diff --git a/PowerEditor/src/menuCmdID.h b/PowerEditor/src/menuCmdID.h
index 7b3b25af4..7e2316362 100644
--- a/PowerEditor/src/menuCmdID.h
+++ b/PowerEditor/src/menuCmdID.h
@@ -258,7 +258,7 @@
#define IDM_VIEW_DRAWTABBAR_INACIVETAB (IDM_VIEW + 8)
#define IDM_VIEW_POSTIT (IDM_VIEW + 9)
#define IDM_VIEW_TOGGLE_FOLDALL (IDM_VIEW + 10)
- //#define IDM_VIEW_USER_DLG (IDM_VIEW + 11)
+ #define IDM_VIEW_DISTRACTIONFREE (IDM_VIEW + 11)
#define IDM_VIEW_LINENUMBER (IDM_VIEW + 12)
#define IDM_VIEW_SYMBOLMARGIN (IDM_VIEW + 13)
#define IDM_VIEW_FOLDERMAGIN (IDM_VIEW + 14)