Skip to content

Commit 8586f3b

Browse files
UffeJakobsenJarod42
authored andcommitted
Statusbar: ensure that statusbar elements can be controlled via preferences - make field properly sized for its contents
1 parent 1dafdb8 commit 8586f3b

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

CodeLite/cl_config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class WXDLLIMPEXP_CL clConfigItem
8282
#define kConfigStatusbarShowPosition "StatusbarShowPosition"
8383
#define kConfigStatusbarShowLength "StatusbarShowLength"
8484
#define kConfigStatusbarShowSelectedChars "StatusbarShowSelChars"
85+
#define kConfigStatusbarShowSelectedLines "StatusbarShowSelLines"
8586
#define kConfigToolbarGroupSpacing "ToolbarGroupSpacing"
8687
#define kConfigAutoDetectCompilerOnStartup "AutoDetectCompilerOnStartup"
8788
#define kConfigBootstrapCompleted "BootstrapCompleted"

LiteEditor/cl_editor.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,9 +1500,11 @@ void clEditor::OnSciUpdateUI(wxStyledTextEvent& event)
15001500
if (m_statusBarFields & kShowLen) {
15011501
message << (!message.empty() ? ", " : "") << "Len " << GetLength();
15021502
}
1503-
15041503
if ((m_statusBarFields & kShowSelectedChars) && selectionSize) {
1505-
message << (!message.empty() ? ", " : "") << "Sel " << selectionSize << ", SelLn " << selectionLn;
1504+
message << (!message.empty() ? ", " : "") << "Sel " << selectionSize;
1505+
}
1506+
if ((m_statusBarFields & kShowSelectedLines) && selectionSize && selectionLn) {
1507+
message << (!message.empty() ? ", " : "") << "SelLn " << selectionLn;
15061508
}
15071509

15081510
// Always update the status bar with event, calling it directly causes performance degradation
@@ -6135,6 +6137,9 @@ void clEditor::PreferencesChanged()
61356137
if (clConfig::Get().Read(kConfigStatusbarShowSelectedChars, true)) {
61366138
m_statusBarFields |= kShowSelectedChars;
61376139
}
6140+
if (clConfig::Get().Read(kConfigStatusbarShowSelectedLines, true)) {
6141+
m_statusBarFields |= kShowSelectedLines;
6142+
}
61386143
}
61396144

61406145
void clEditor::NotifyMarkerChanged(int lineNumber)

LiteEditor/cl_editor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ class clEditor : public wxStyledTextCtrl, public IEditor
231231
kShowPosition = (1 << 2),
232232
kShowLen = (1 << 3),
233233
kShowSelectedChars = (1 << 4),
234+
kShowSelectedLines = (1 << 5),
234235
};
235236

236237
enum eLineStatus : short {

LiteEditor/editorsettingsmiscpanel.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ EditorSettingsMiscPanel::EditorSettingsMiscPanel(wxWindow* parent, OptionsConfig
8989
UPDATE_CLCONFIG_BOOL_CB(kConfigStatusbarShowLength));
9090
AddProperty(_("Show number of selected chars"), clConfig::Get().Read(kConfigStatusbarShowSelectedChars, true),
9191
UPDATE_CLCONFIG_BOOL_CB(kConfigStatusbarShowSelectedChars));
92+
AddProperty(_("Show number of selected lines"), clConfig::Get().Read(kConfigStatusbarShowSelectedLines, true),
93+
UPDATE_CLCONFIG_BOOL_CB(kConfigStatusbarShowSelectedLines));
9294

9395
AddHeader(_("Tool bar"));
9496
AddProperty(_("Space between button groups"), clConfig::Get().Read(kConfigToolbarGroupSpacing, 30),

Plugin/clStatusBar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ clStatusBar::clStatusBar(wxWindow* parent, IManager* mgr)
9999
new wxCustomStatusBarBitmapField(this, clGetScaledSize(30) + lable_width));
100100
STATUSBAR_SCM_IDX = AddField(sourceControl);
101101

102-
int lineColWidth = GetTextWidth("Ln 100000, Col 999, Pos 12345678, Len 4821182");
102+
const int lineColWidth = GetTextWidth("Ln 123456, Col 123, Pos 12345678, Len 12345678, Sel 1234567, SelLn 12345");
103103
wxCustomStatusBarField::Ptr_t lineCol(new wxCustomStatusBarFieldText(this, lineColWidth));
104104
STATUSBAR_LINE_COL_IDX = AddField(lineCol);
105105

0 commit comments

Comments
 (0)