Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion locales/en.catkeys
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1 English x-vnd.KapiX-Koder 3292494141
1 English x-vnd.KapiX-Koder 4243475505
Something wrong has happened while opening the configuration file. Your personal settings will not be %s%. Preferences Something wrong has happened while opening the configuration file. Your personal settings will not be %s%.
Access denied EditorWindow Access denied
Line endings EditorWindow Line endings
Expand Down Expand Up @@ -156,6 +156,7 @@ Unix format EditorWindow Unix format
Open Terminal EditorStatusView Open Terminal
File modified EditorWindow File modified
Highlight braces AppPreferencesWindow Highlight braces
Show bold folding markers AppPreferencesWindow Show bold folding markers
Save selected QuitAlert Save selected
Max. characters per line: AppPreferencesWindow Max. characters per line:
Use block cursor AppPreferencesWindow Use block cursor
Expand Down
27 changes: 26 additions & 1 deletion src/editor/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Editor::Editor()
fFoldMarginEnabled(false),
fBookmarkMarginEnabled(false),
fBracesHighlightingEnabled(false),
fBoldFoldMarkersEnabled(false),
fTrailingWSHighlightingEnabled(false),
fType(""),
fReadOnly(false)
Expand Down Expand Up @@ -478,7 +479,7 @@ Editor::SetFoldMarginEnabled(bool enabled)
fFoldMarginEnabled = enabled;
const int foldEnabled = SendMessage(SCI_GETPROPERTYINT, (uptr_t) "fold", 0);
const int32 fontSize = SendMessage(SCI_STYLEGETSIZE, 32);
const int32 foldWidth = foldEnabled && enabled ? fontSize * 0.95 : 0;
const int32 foldWidth = foldEnabled && enabled ? fontSize * (fBoldFoldMarkersEnabled ? 1.25 : 0.95) : 0;
SendMessage(SCI_SETMARGINWIDTHN, Margin::FOLD, foldWidth);
}

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


void
Editor::SetBoldFoldMarkersEnabled(bool enabled)
{
if(fBoldFoldMarkersEnabled == enabled) {
// no changes needed
return;
}

const int32 strokeWidth = enabled ? 300 : 100;
SendMessage(SCI_MARKERSETSTROKEWIDTH, SC_MARKNUM_FOLDER, strokeWidth);
SendMessage(SCI_MARKERSETSTROKEWIDTH, SC_MARKNUM_FOLDEROPEN, strokeWidth);
SendMessage(SCI_MARKERSETSTROKEWIDTH, SC_MARKNUM_FOLDEREND, strokeWidth);
SendMessage(SCI_MARKERSETSTROKEWIDTH, SC_MARKNUM_FOLDERMIDTAIL, strokeWidth);
SendMessage(SCI_MARKERSETSTROKEWIDTH, SC_MARKNUM_FOLDEROPENMID, strokeWidth);
SendMessage(SCI_MARKERSETSTROKEWIDTH, SC_MARKNUM_FOLDEROPEN, strokeWidth);
SendMessage(SCI_MARKERSETSTROKEWIDTH, SC_MARKNUM_FOLDERSUB, strokeWidth);
SendMessage(SCI_MARKERSETSTROKEWIDTH, SC_MARKNUM_FOLDERTAIL, strokeWidth);

fBoldFoldMarkersEnabled = enabled;
// reset our margin width
SetFoldMarginEnabled(fFoldMarginEnabled);
}


void
Editor::SetTrailingWSHighlightingEnabled(bool enabled)
{
Expand Down
2 changes: 2 additions & 0 deletions src/editor/Editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class Editor : public BScintillaView {
void SetFoldMarginEnabled(bool enabled);
void SetBookmarkMarginEnabled(bool enabled);
void SetBracesHighlightingEnabled(bool enabled);
void SetBoldFoldMarkersEnabled(bool enabled);
void SetTrailingWSHighlightingEnabled(bool enabled);

std::string SelectionText();
Expand Down Expand Up @@ -124,6 +125,7 @@ class Editor : public BScintillaView {
bool fFoldMarginEnabled;
bool fBookmarkMarginEnabled;
bool fBracesHighlightingEnabled;
bool fBoldFoldMarkersEnabled;
bool fTrailingWSHighlightingEnabled;

// needed for StatusView
Expand Down
1 change: 1 addition & 0 deletions src/editor/EditorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,7 @@ EditorWindow::_SyncWithPreferences()
fEditor->SetBookmarkMarginEnabled(fPreferences->fBookmarkMargin);
fEditor->SetBracesHighlightingEnabled(
fPreferences->fBracesHighlighting);
fEditor->SetBoldFoldMarkersEnabled(fPreferences->fBoldFoldMarkers);
fEditor->SetTrailingWSHighlightingEnabled(
fPreferences->fHighlightTrailingWhitespace);

Expand Down
7 changes: 7 additions & 0 deletions src/preferences/AppPreferencesWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ AppPreferencesWindow::MessageReceived(BMessage* message)
fPreferences->fUseBlockCursor = IsChecked(fBlockCursorCB);
_PreferencesModified();
} break;
case Actions::BOLD_FOLD_MARKERS: {
fPreferences->fBoldFoldMarkers = IsChecked(fBoldFoldMarkersCB);
_PreferencesModified();
} break;
case Actions::EDITOR_STYLE: {
fPreferences->fStyle = message->GetString("style", "default");
_PreferencesModified();
Expand Down Expand Up @@ -335,6 +339,7 @@ AppPreferencesWindow::_InitInterface()

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

fEditorStyleMenu = new BPopUpMenu("style");
fEditorStyleMF = new BMenuField("style", B_TRANSLATE("Style"), fEditorStyleMenu);
Expand Down Expand Up @@ -374,6 +379,7 @@ AppPreferencesWindow::_InitInterface()
.Add(fFullPathInTitleCB)
.Add(fBracesHighlightingCB)
.Add(fBlockCursorCB)
.Add(fBoldFoldMarkersCB)
.Add(fToolbarBox)
.AddStrut(B_USE_HALF_ITEM_SPACING)
.Add(fLineLimitBox)
Expand Down Expand Up @@ -479,6 +485,7 @@ AppPreferencesWindow::_SyncPreferences(Preferences* preferences)

SetChecked(fBracesHighlightingCB, preferences->fBracesHighlighting);
SetChecked(fBlockCursorCB, preferences->fUseBlockCursor);
SetChecked(fBoldFoldMarkersCB, preferences->fBoldFoldMarkers);
SetChecked(fAttachNewWindowsCB, preferences->fOpenWindowsInStack);
SetChecked(fHighlightTrailingWSCB, preferences->fHighlightTrailingWhitespace);
SetChecked(fTrimTrailingWSOnSaveCB, preferences->fTrimTrailingWhitespaceOnSave);
Expand Down
2 changes: 2 additions & 0 deletions src/preferences/AppPreferencesWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class AppPreferencesWindow : public BWindow {
TOOLBAR_ICON_SIZE = 'tlis',
FULL_PATH_IN_TITLE = 'fpit',
BLOCK_CURSOR = 'bloc',
BOLD_FOLD_MARKERS = 'bfld',
TABS_TO_SPACES = 'ttsp',
TAB_WIDTH = 'tbwd',
LINE_HIGHLIGHTING = 'lhlt',
Expand Down Expand Up @@ -136,6 +137,7 @@ class AppPreferencesWindow : public BWindow {

BCheckBox* fBracesHighlightingCB;
BCheckBox* fBlockCursorCB;
BCheckBox* fBoldFoldMarkersCB;

BPopUpMenu* fEditorStyleMenu;
BMenuField* fEditorStyleMF;
Expand Down
3 changes: 3 additions & 0 deletions src/preferences/Preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Preferences::Load(const char* filename)
fLineHighlighting = storage.GetBool("lineHighlighting", true);
fLineHighlightingMode = storage.GetUInt8("lineHighlightingMode", 0);
fLineNumbers = storage.GetBool("lineNumbers", true);
fBoldFoldMarkers = storage.GetBool("boldFoldMarkers", false);
fFoldMargin = storage.GetBool("foldMargin", true);
fBookmarkMargin = storage.GetBool("bookmarkMargin", true);
fIndentGuidesShow = storage.GetBool("indentGuidesShow", true);
Expand Down Expand Up @@ -135,6 +136,7 @@ Preferences::Save(const char* filename)
storage.AddBool("lineHighlighting", fLineHighlighting);
storage.AddUInt8("lineHighlightingMode", fLineHighlightingMode);
storage.AddBool("lineNumbers", fLineNumbers);
storage.AddBool("boldFoldMarkers", fBoldFoldMarkers);
storage.AddBool("foldMargin", fFoldMargin);
storage.AddBool("bookmarkMargin", fBookmarkMargin);
storage.AddBool("whiteSpaceVisible", fWhiteSpaceVisible);
Expand Down Expand Up @@ -179,6 +181,7 @@ Preferences::operator =(Preferences& p)
fLineHighlighting = p.fLineHighlighting;
fLineHighlightingMode = p.fLineHighlightingMode;
fLineNumbers = p.fLineNumbers;
fBoldFoldMarkers = p.fBoldFoldMarkers;
fFoldMargin = p.fFoldMargin;
fBookmarkMargin = p.fBookmarkMargin;
fEOLVisible = p.fEOLVisible;
Expand Down
1 change: 1 addition & 0 deletions src/preferences/Preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Preferences {
uint8 fLineHighlightingMode;
bool fLineNumbers;
bool fFoldMargin;
bool fBoldFoldMarkers;
bool fBookmarkMargin;
bool fEOLVisible;
bool fWhiteSpaceVisible;
Expand Down