Skip to content

Commit bf1eb18

Browse files
committed
Add option to use bolder folding markers in the margin
1 parent cf803c5 commit bf1eb18

File tree

7 files changed

+42
-1
lines changed

7 files changed

+42
-1
lines changed

src/editor/Editor.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Editor::Editor()
3131
fFoldMarginEnabled(false),
3232
fBookmarkMarginEnabled(false),
3333
fBracesHighlightingEnabled(false),
34+
fBoldFoldMarkersEnabled(false),
3435
fTrailingWSHighlightingEnabled(false),
3536
fType(""),
3637
fReadOnly(false)
@@ -478,7 +479,7 @@ Editor::SetFoldMarginEnabled(bool enabled)
478479
fFoldMarginEnabled = enabled;
479480
const int foldEnabled = SendMessage(SCI_GETPROPERTYINT, (uptr_t) "fold", 0);
480481
const int32 fontSize = SendMessage(SCI_STYLEGETSIZE, 32);
481-
const int32 foldWidth = foldEnabled && enabled ? fontSize * 0.95 : 0;
482+
const int32 foldWidth = foldEnabled && enabled ? fontSize * (fBoldFoldMarkersEnabled ? 1.25 : 0.95) : 0;
482483
SendMessage(SCI_SETMARGINWIDTHN, Margin::FOLD, foldWidth);
483484
}
484485

@@ -501,6 +502,30 @@ Editor::SetBracesHighlightingEnabled(bool enabled)
501502
}
502503

503504

505+
void
506+
Editor::SetBoldFoldMarkersEnabled(bool enabled)
507+
{
508+
if(fBoldFoldMarkersEnabled == enabled) {
509+
// no changes needed
510+
return;
511+
}
512+
513+
const int32 strokeWidth = enabled ? 300 : 100;
514+
SendMessage(SCI_MARKERSETSTROKEWIDTH, SC_MARKNUM_FOLDER, strokeWidth);
515+
SendMessage(SCI_MARKERSETSTROKEWIDTH, SC_MARKNUM_FOLDEROPEN, strokeWidth);
516+
SendMessage(SCI_MARKERSETSTROKEWIDTH, SC_MARKNUM_FOLDEREND, strokeWidth);
517+
SendMessage(SCI_MARKERSETSTROKEWIDTH, SC_MARKNUM_FOLDERMIDTAIL, strokeWidth);
518+
SendMessage(SCI_MARKERSETSTROKEWIDTH, SC_MARKNUM_FOLDEROPENMID, strokeWidth);
519+
SendMessage(SCI_MARKERSETSTROKEWIDTH, SC_MARKNUM_FOLDEROPEN, strokeWidth);
520+
SendMessage(SCI_MARKERSETSTROKEWIDTH, SC_MARKNUM_FOLDERSUB, strokeWidth);
521+
SendMessage(SCI_MARKERSETSTROKEWIDTH, SC_MARKNUM_FOLDERTAIL, strokeWidth);
522+
523+
fBoldFoldMarkersEnabled = enabled;
524+
// reset our margin width
525+
SetFoldMarginEnabled(fFoldMarginEnabled);
526+
}
527+
528+
504529
void
505530
Editor::SetTrailingWSHighlightingEnabled(bool enabled)
506531
{

src/editor/Editor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class Editor : public BScintillaView {
9090
void SetFoldMarginEnabled(bool enabled);
9191
void SetBookmarkMarginEnabled(bool enabled);
9292
void SetBracesHighlightingEnabled(bool enabled);
93+
void SetBoldFoldMarkersEnabled(bool enabled);
9394
void SetTrailingWSHighlightingEnabled(bool enabled);
9495

9596
std::string SelectionText();
@@ -124,6 +125,7 @@ class Editor : public BScintillaView {
124125
bool fFoldMarginEnabled;
125126
bool fBookmarkMarginEnabled;
126127
bool fBracesHighlightingEnabled;
128+
bool fBoldFoldMarkersEnabled;
127129
bool fTrailingWSHighlightingEnabled;
128130

129131
// needed for StatusView

src/editor/EditorWindow.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,7 @@ EditorWindow::_SyncWithPreferences()
12191219
fEditor->SetBookmarkMarginEnabled(fPreferences->fBookmarkMargin);
12201220
fEditor->SetBracesHighlightingEnabled(
12211221
fPreferences->fBracesHighlighting);
1222+
fEditor->SetBoldFoldMarkersEnabled(fPreferences->fBoldFoldMarkers);
12221223
fEditor->SetTrailingWSHighlightingEnabled(
12231224
fPreferences->fHighlightTrailingWhitespace);
12241225

src/preferences/AppPreferencesWindow.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ AppPreferencesWindow::MessageReceived(BMessage* message)
160160
fPreferences->fUseBlockCursor = IsChecked(fBlockCursorCB);
161161
_PreferencesModified();
162162
} break;
163+
case Actions::BOLD_FOLD_MARKERS: {
164+
fPreferences->fBoldFoldMarkers = IsChecked(fBoldFoldMarkersCB);
165+
_PreferencesModified();
166+
} break;
163167
case Actions::EDITOR_STYLE: {
164168
fPreferences->fStyle = message->GetString("style", "default");
165169
_PreferencesModified();
@@ -335,6 +339,7 @@ AppPreferencesWindow::_InitInterface()
335339

336340
fBracesHighlightingCB = new BCheckBox("bracesHighlighting", B_TRANSLATE("Highlight braces"), new BMessage((uint32) Actions::BRACES_HIGHLIGHTING));
337341
fBlockCursorCB = new BCheckBox("blockCursor", B_TRANSLATE("Use block cursor"), new BMessage((uint32) Actions::BLOCK_CURSOR));
342+
fBoldFoldMarkersCB = new BCheckBox("boldFoldMarkers", B_TRANSLATE("Show bold folding markers"), new BMessage((uint32) Actions::BOLD_FOLD_MARKERS));
338343

339344
fEditorStyleMenu = new BPopUpMenu("style");
340345
fEditorStyleMF = new BMenuField("style", B_TRANSLATE("Style"), fEditorStyleMenu);
@@ -374,6 +379,7 @@ AppPreferencesWindow::_InitInterface()
374379
.Add(fFullPathInTitleCB)
375380
.Add(fBracesHighlightingCB)
376381
.Add(fBlockCursorCB)
382+
.Add(fBoldFoldMarkersCB)
377383
.Add(fToolbarBox)
378384
.AddStrut(B_USE_HALF_ITEM_SPACING)
379385
.Add(fLineLimitBox)
@@ -479,6 +485,7 @@ AppPreferencesWindow::_SyncPreferences(Preferences* preferences)
479485

480486
SetChecked(fBracesHighlightingCB, preferences->fBracesHighlighting);
481487
SetChecked(fBlockCursorCB, preferences->fUseBlockCursor);
488+
SetChecked(fBoldFoldMarkersCB, preferences->fBoldFoldMarkers);
482489
SetChecked(fAttachNewWindowsCB, preferences->fOpenWindowsInStack);
483490
SetChecked(fHighlightTrailingWSCB, preferences->fHighlightTrailingWhitespace);
484491
SetChecked(fTrimTrailingWSOnSaveCB, preferences->fTrimTrailingWhitespaceOnSave);

src/preferences/AppPreferencesWindow.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class AppPreferencesWindow : public BWindow {
4343
TOOLBAR_ICON_SIZE = 'tlis',
4444
FULL_PATH_IN_TITLE = 'fpit',
4545
BLOCK_CURSOR = 'bloc',
46+
BOLD_FOLD_MARKERS = 'bfld',
4647
TABS_TO_SPACES = 'ttsp',
4748
TAB_WIDTH = 'tbwd',
4849
LINE_HIGHLIGHTING = 'lhlt',
@@ -136,6 +137,7 @@ class AppPreferencesWindow : public BWindow {
136137

137138
BCheckBox* fBracesHighlightingCB;
138139
BCheckBox* fBlockCursorCB;
140+
BCheckBox* fBoldFoldMarkersCB;
139141

140142
BPopUpMenu* fEditorStyleMenu;
141143
BMenuField* fEditorStyleMF;

src/preferences/Preferences.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ Preferences::Load(const char* filename)
9191
fLineHighlighting = storage.GetBool("lineHighlighting", true);
9292
fLineHighlightingMode = storage.GetUInt8("lineHighlightingMode", 0);
9393
fLineNumbers = storage.GetBool("lineNumbers", true);
94+
fBoldFoldMarkers = storage.GetBool("boldFoldMarkers", false);
9495
fFoldMargin = storage.GetBool("foldMargin", true);
9596
fBookmarkMargin = storage.GetBool("bookmarkMargin", true);
9697
fIndentGuidesShow = storage.GetBool("indentGuidesShow", true);
@@ -135,6 +136,7 @@ Preferences::Save(const char* filename)
135136
storage.AddBool("lineHighlighting", fLineHighlighting);
136137
storage.AddUInt8("lineHighlightingMode", fLineHighlightingMode);
137138
storage.AddBool("lineNumbers", fLineNumbers);
139+
storage.AddBool("boldFoldMarkers", fBoldFoldMarkers);
138140
storage.AddBool("foldMargin", fFoldMargin);
139141
storage.AddBool("bookmarkMargin", fBookmarkMargin);
140142
storage.AddBool("whiteSpaceVisible", fWhiteSpaceVisible);
@@ -179,6 +181,7 @@ Preferences::operator =(Preferences& p)
179181
fLineHighlighting = p.fLineHighlighting;
180182
fLineHighlightingMode = p.fLineHighlightingMode;
181183
fLineNumbers = p.fLineNumbers;
184+
fBoldFoldMarkers = p.fBoldFoldMarkers;
182185
fFoldMargin = p.fFoldMargin;
183186
fBookmarkMargin = p.fBookmarkMargin;
184187
fEOLVisible = p.fEOLVisible;

src/preferences/Preferences.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class Preferences {
3737
uint8 fLineHighlightingMode;
3838
bool fLineNumbers;
3939
bool fFoldMargin;
40+
bool fBoldFoldMarkers;
4041
bool fBookmarkMargin;
4142
bool fEOLVisible;
4243
bool fWhiteSpaceVisible;

0 commit comments

Comments
 (0)