From 4bdb4a7e70e41cb3bd331ab0e8704730e8b902ca Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Thu, 26 Apr 2018 11:55:02 +0200 Subject: [PATCH] + fix: small bug preventing Statusbar relative width settings smaller than 1/10 of width --- Build/Notepad3.ini | Bin 5782 -> 5798 bytes src/Helpers.c | 6 +++--- src/Notepad3.c | 16 +++++++++------- src/TypeDefs.h | 3 ++- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Build/Notepad3.ini b/Build/Notepad3.ini index 02e7aca126d53476956fe5fb433185641c71d9c5..7a5a526405a420a109d2efe662c495ce5c4600a8 100644 GIT binary patch delta 72 scmbQHyG(b34!5}hg93vQ1BA3dVk3)#*yc#sn89o^Be&@03~oJc0C=4Vng9R* delta 56 pcmZ3cJ56_k4!61jgAs!QgE0_;Xk=^%WJYe$%@y2w+yM1l2m1g3 diff --git a/src/Helpers.c b/src/Helpers.c index 9d16c8257..75b3c17bd 100644 --- a/src/Helpers.c +++ b/src/Helpers.c @@ -1007,7 +1007,7 @@ LONG StatusCalcPaneWidth(HWND hwnd,LPCWSTR lpsz) SelectObject(hdc,hfold); ReleaseDC(hwnd,hdc); - return (size.cx + 12L); + return (size.cx + 8L); } @@ -2887,8 +2887,8 @@ int ReadVectorFromString(LPCWSTR wchStrg, int* iVector, int iCount, int iMin, in while (*p) { int iValue; if (swscanf_s(p, L"%i", &iValue) == 1) { - if ((n < iCount) && (iValue >= iMin) && (iValue <= iMax)) { - iVector[n++] = iValue; + if (n < iCount) { + iVector[n++] = min(max(iValue, iMin), iMax); } } p = StrEnd(p) + 1; diff --git a/src/Notepad3.c b/src/Notepad3.c index f7fdb631f..05f02ab2c 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -742,29 +742,31 @@ static int g_aSBSOrder[STATUS_SECTOR_COUNT]; // _StatusbarSetSections() // // -static void __fastcall _StatusbarSetSections(int cx) +static void __fastcall _StatusbarSetSections(int width) { - static int lastCX = -1; - if (!bShowStatusbar || (cx == lastCX)) { return; } // static calculation + static int lastWinWidth = -1; + width -= STAUSBAR_RIGHT_MARGIN; + + if (!bShowStatusbar || (width < 0) || (width == lastWinWidth)) { return; } // static calculation // prepare sector array for (int i = 0; i < STATUS_SECTOR_COUNT; ++i) { g_vStatusbarSectionWidth[i] = -1; - g_aSBSOrder[i] = -1; + g_aSBSOrder[i] = i; } int vSections[STATUS_SECTOR_COUNT]; ReadVectorFromString(g_tchStatusbarSections, vSections, STATUS_SECTOR_COUNT, 0, (STATUS_SECTOR_COUNT - 1), -1); int vWeights[STATUS_SECTOR_COUNT]; - ReadVectorFromString(g_tchStatusbarRelWidths, vWeights, STATUS_SECTOR_COUNT, 0, (STATUS_SECTOR_COUNT - 1), 1); + ReadVectorFromString(g_tchStatusbarRelWidths, vWeights, STATUS_SECTOR_COUNT, 0, 4096, 1); int cnt = 0; int totalWeight = 0; for (int i = 0; i < STATUS_SECTOR_COUNT; ++i) { int const iID = vSections[i]; if (iID != -1) { - g_vStatusbarSectionWidth[iID] = (cx * vWeights[iID]); + g_vStatusbarSectionWidth[iID] = (width * vWeights[iID]); totalWeight += vWeights[iID]; g_aSBSOrder[cnt++] = iID; } @@ -777,7 +779,7 @@ static void __fastcall _StatusbarSetSections(int cx) } } } - lastCX = cx; + lastWinWidth = width; } diff --git a/src/TypeDefs.h b/src/TypeDefs.h index 43d36b986..217d99112 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -91,8 +91,9 @@ typedef enum { } STATUS_SECTOR_T; #define STATUSBAR_DEFAULT_IDS L"0 1 2 3 4 5 6 7 8 9 10" -#define STATUSBAR_SECTION_WIDTH L"2 2 3 2 2 2 2 1 1 1 3" +#define STATUSBAR_SECTION_WIDTH L"20 20 28 20 20 20 20 7 7 7 36" #define STATUSBAR_EXTION_PREFIXES L"Ln ,Col ,Sel ,SelLn ,Occ ,,,,,,,," +#define STAUSBAR_RIGHT_MARGIN 20 // --------------------------------------------------------------------------