Add Edit::ToggleLineNumbers() to the sample

Make it a bit simpler to show line numbers when showing the minimap.
This commit is contained in:
Vadim Zeitlin
2025-10-16 23:54:39 +02:00
parent 68a55e9c9b
commit 42e87852eb
3 changed files with 9 additions and 2 deletions
+4
View File
@@ -320,6 +320,10 @@ void Edit::OnIndentGuide (wxCommandEvent &WXUNUSED(event)) {
}
void Edit::OnLineNumber (wxCommandEvent &WXUNUSED(event)) {
ToggleLineNumbers();
}
void Edit::ToggleLineNumbers() {
SetMarginWidth (m_LineNrID,
GetMarginWidth (m_LineNrID) == 0? m_LineNrMargin: 0);
}
+3
View File
@@ -131,6 +131,9 @@ public:
wxString GetFilename () {return m_filename;}
void SetFilename (const wxString &filename) {m_filename = filename;}
// Toggle showing line numbers in the margin.
void ToggleLineNumbers();
private:
// file
wxString m_filename;
+2 -2
View File
@@ -1616,8 +1616,8 @@ void App::ShowDocumentMap(wxWindow* parent)
auto* const edit = new Edit(splitter);
edit->LoadFile("stctest.cpp");
// Show line numbers and hide the other margins not used here.
edit->SetMarginWidth(0, edit->GetTextExtent("99999").x);
// Show line numbers in the margin, which are hidden by default.
edit->ToggleLineNumbers();
edit->SetWrapMode(wxSTC_WRAP_WORD);
edit->SetWrapVisualFlags(wxSTC_WRAPVISUALFLAG_END);