Skip to content

Commit

Permalink
Support size adjustment for code folding margin width, issue #940.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Dec 17, 2024
1 parent 840401c commit 8e43a82
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
7 changes: 1 addition & 6 deletions src/Notepad4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ int iChangeHistoryMarker;
EditAutoCompletionConfig autoCompletionConfig;
int iSelectOption;
static int iLineSelectionMode;
static bool bShowCodeFolding;
bool bShowCodeFolding;
extern CallTipInfo callTipInfo;
static bool bViewWhiteSpace;
static bool bViewEOLs;
Expand Down Expand Up @@ -1650,11 +1650,6 @@ void UpdateBookmarkMarginWidth() noexcept {
SciCall_SetMarginWidth(MarginNumber_Bookmark, width);
}

void UpdateFoldMarginWidth() noexcept {
const int width = bShowCodeFolding ? SciCall_TextWidth(STYLE_LINENUMBER, "+_") : 0;
SciCall_SetMarginWidth(MarginNumber_CodeFolding, width);
}

void SetWrapVisualFlags() noexcept {
if (bShowWordWrapSymbols) {
int wrapVisualFlags = 0;
Expand Down
22 changes: 19 additions & 3 deletions src/Styles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,10 @@ extern int iDefaultCodePage;
extern int iDefaultCharSet;
extern LineHighlightMode iHighlightCurrentLine;
extern bool bShowBookmarkMargin;
extern bool bShowCodeFolding;
extern int iZoomLevel;
extern bool bUseXPFileDialog;
extern bool flagSimpleIndentGuides;

// LF_FACESIZE is 32, LOCALE_NAME_MAX_LENGTH is 85
#define MAX_STYLE_VALUE_LENGTH LOCALE_NAME_MAX_LENGTH
Expand Down Expand Up @@ -392,7 +394,7 @@ enum GlobalStyleIndex {
GlobalStyleIndex_IMEIndicator, // indicator style. `fore`: IME indicator color
GlobalStyleIndex_LongLineMarker, // standalone style. `fore`: edge line color, `back`: background color for text exceeds long line limit
GlobalStyleIndex_ExtraLineSpacing, // standalone style. descent = `size`/2, ascent = `size` - descent
GlobalStyleIndex_CodeFolding, // standalone style. `fore`, `back`
GlobalStyleIndex_CodeFolding, // standalone style. `fore`, `back`, `size`
GlobalStyleIndex_FoldingMarker, // standalone style. `fore`: folding line color, `back`: plus/minus box fill color
GlobalStyleIndex_FoldDispalyText, // inherited style.
GlobalStyleIndex_MarkOccurrences, // indicator style. `fore`, `alpha`, `outline`
Expand Down Expand Up @@ -3085,8 +3087,6 @@ void Style_HighlightCurrentLine() noexcept {
//
// Style_SetIndentGuides()
//
extern bool flagSimpleIndentGuides;

void Style_SetIndentGuides(bool bShow) noexcept {
int iIndentView = SC_IV_NONE;
if (bShow) {
Expand Down Expand Up @@ -3149,6 +3149,22 @@ void Style_SetBookmark() noexcept {
bBookmarkColorUpdated = false;
}

void UpdateFoldMarginWidth() noexcept {
int width = 0;
if (bShowCodeFolding) {
LPCWSTR szValue = lexGlobal.Styles[GlobalStyleIndex_CodeFolding].szValue;
Style_StrGetSize(szValue, &width);
if (width != 0) {
const int scale = g_uCurrentDPI*iZoomLevel;
if (scale != USER_DEFAULT_SCREEN_DPI*100) {
width = MulDiv(width, scale, USER_DEFAULT_SCREEN_DPI*100);
}
}
width += SciCall_TextWidth(STYLE_LINENUMBER, "+_");
}
SciCall_SetMarginWidth(MarginNumber_CodeFolding, width);
}

//=============================================================================
//
// Style_GetOpenDlgFilterStr()
Expand Down
2 changes: 1 addition & 1 deletion wiki
Submodule wiki updated from aa78a9 to 26ee35

0 comments on commit 8e43a82

Please sign in to comment.