https://github.com/wxWidgets/wxWidgets/pull/25887
(25 files)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
@vadz pushed 1 commit.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
@vadz pushed 2 commits.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Nice! Looking forward to use this.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
@vadz pushed 2 commits.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
I think this should be good to merge now. The API is (intentionally) very simple, the idea is that you can simply create a mini map for an existing control and it just works.
Please let me know if anybody has any comments/objections!
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
One of the more useful things I am using mini-map (in my case, I implemented it as a second wxSTC which I am manually syncing between the two) is the ability to view error markers.
It comes in very handy to be able to view all the compiler errors / warnings on the minimap and quickly jump to fix them. I tried to manually add a marker in the "main" edit view, but it does not being reflected in the "mini-map".
Can this be done easily?
minimap.png (view on web)—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
This is indeed not supported currently, but I think it could be done by mirroring calls to Marker{Add,Delete,DeleteAll}() to the minimap control just as it's currently done for folds.
Markers seem to be simpler, so it should be already possible to just call all these functions on both the main editor and the map manually, but we could still replace SetMirrorFoldingCtrl() by just SetMirrorCtrl() and mirror them there automatically.
Can you confirm that doing this would work for you (by checking if calling MarkerAdd() manually does)?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Sure, will try this locally.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
It works.
Below is a diff of the changes I did. A quick summary of the changes (I also did a small change to the CMakeLists.txt to generate a compile_commands.json so code completion with clangd will work flawlessly):
Refactor mirror control to synchronize markers in addition to folding
SetMirrorFoldingCtrl() to SetMirrorCtrl() to reflect expanded functionalitym_mirrorFoldingCtrl to m_mirrorCtrlCMAKE_EXPORT_COMPILE_COMMANDS for better IDE/tooling supportcompile_commands.json in source directorydiff --git a/CMakeLists.txt b/CMakeLists.txt index 8bec92df37..bba94566bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,8 @@ cmake_minimum_required(VERSION 3.5...4.1) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + if(NOT CMAKE_CONFIGURATION_TYPES) get_property(HAVE_MULTI_CONFIG_GENERATOR GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) # Set default configuration types for multi-config generators @@ -106,3 +108,8 @@ include(build/cmake/main.cmake) if(wxBUILD_SAMPLES AND wxUSE_GUI) set_directory_properties(PROPERTIES VS_STARTUP_PROJECT minimal) endif() + +file(CREATE_LINK + "${CMAKE_BINARY_DIR}/compile_commands.json" + "${CMAKE_SOURCE_DIR}/compile_commands.json" + SYMBOLIC) diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index 46c0051e75..cc00edce36 100644 --- a/include/wx/stc/stc.h +++ b/include/wx/stc/stc.h @@ -5853,10 +5853,13 @@ public: %pythoncode "_stc_utf8_methods.py" #endif - // Specify that folding in the given control should be synchronized with - // folding in this control, i.e. whenever a fold is opened/closed in this - // one, it will be opened/closed in the mirror control as well. - void SetMirrorFoldingCtrl(wxStyledTextCtrl* mirrorFoldingCtrl); + // Establishes a mirror control to keep synchronized with this control. + // When set, folding states and markers are automatically synchronized between + // this control and the specified mirror control. + // + // @param mirrorCtrl Pointer to the wxStyledTextCtrl to use as mirror control, + // or nullptr to remove the mirror relationship. + void SetMirrorCtrl(wxStyledTextCtrl* mirrorCtrl); // implement wxTextEntryBase pure virtual methods @@ -6122,7 +6125,7 @@ protected: private: wxBitmap m_buffer; - wxStyledTextCtrl* m_mirrorFoldingCtrl = nullptr; + wxStyledTextCtrl* m_mirrorCtrl = nullptr; friend class ScintillaWX; #endif // !SWIG diff --git a/samples/stc/stctest.cpp b/samples/stc/stctest.cpp index 2cc884de70..f16c17a1e9 100644 --- a/samples/stc/stctest.cpp +++ b/samples/stc/stctest.cpp @@ -898,8 +898,6 @@ void App::ShowDocumentMap(wxWindow* parent) auto* const edit = new Edit(splitter); edit->LoadFile("C:\\msys64\\home\\eran\\devl\\codelite\\Plugin\\ai\\LLMManager.cpp"); - edit->MarkerDefine(3, wxSTC_MARK_ROUNDRECT, *wxRED, *wxRED); - edit->MarkerAdd(10, 3); // Show line numbers in the margin, which are hidden by default. edit->ToggleLineNumbers(); @@ -907,7 +905,11 @@ void App::ShowDocumentMap(wxWindow* parent) edit->SetWrapMode(wxSTC_WRAP_WORD); edit->SetWrapVisualFlags(wxSTC_WRAPVISUALFLAG_END); - auto* const map = new wxStyledTextCtrlMiniMap(splitter, edit); + auto* const map = new wxStyledTextCtrlMiniMap(splitter, edit); + + // Need to add markers after we created the mini-map + edit->MarkerDefine(3, wxSTC_MARK_ROUNDRECT, *wxRED, *wxRED); + edit->MarkerAdd(10, 3); splitter->SplitVertically(edit, map); splitter->SetMinimumPaneSize(dialog.FromDIP(10)); diff --git a/src/stc/minimap.cpp b/src/stc/minimap.cpp index 831d84b413..3df0da869b 100644 --- a/src/stc/minimap.cpp +++ b/src/stc/minimap.cpp @@ -205,7 +205,7 @@ wxStyledTextCtrlMiniMap::Create(wxWindow* parent, wxStyledTextCtrl* edit) SetCursor(wxCURSOR_ARROW); // Ensure that folds in the map are synchronized with the main editor. - edit->SetMirrorFoldingCtrl(this); + edit->SetMirrorCtrl(this); // Scroll the editor when the map is scrolled. Bind(wxEVT_STC_UPDATEUI, &wxStyledTextCtrlMiniMap::OnMapUpdate, this); diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 8acd6c0f85..8ea3b9942a 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -615,53 +615,69 @@ void wxStyledTextCtrl::SetIMEInteraction(int imeInteraction) void wxStyledTextCtrl::MarkerDefine(int markerNumber, int markerSymbol, const wxColour& foreground, const wxColour& background) { + if ( m_mirrorCtrl ) + m_mirrorCtrl->MarkerDefine(markerNumber, markerSymbol, foreground, background); - SendMsg(SCI_MARKERDEFINE, markerNumber, markerSymbol); - if (foreground.IsOk()) - MarkerSetForeground(markerNumber, foreground); - if (background.IsOk()) - MarkerSetBackground(markerNumber, background); + SendMsg(SCI_MARKERDEFINE, markerNumber, markerSymbol); + if (foreground.IsOk()) + MarkerSetForeground(markerNumber, foreground); + if (background.IsOk()) + MarkerSetBackground(markerNumber, background); } // Set the foreground colour used for a particular marker number. void wxStyledTextCtrl::MarkerSetForeground(int markerNumber, const wxColour& fore) { + if ( m_mirrorCtrl ) + m_mirrorCtrl->MarkerSetForeground(markerNumber, fore); SendMsg(SCI_MARKERSETFORE, markerNumber, wxColourAsLong(fore)); } // Set the background colour used for a particular marker number. void wxStyledTextCtrl::MarkerSetBackground(int markerNumber, const wxColour& back) { + if ( m_mirrorCtrl ) + m_mirrorCtrl->MarkerSetForeground(markerNumber, back); SendMsg(SCI_MARKERSETBACK, markerNumber, wxColourAsLong(back)); } // Set the background colour used for a particular marker number when its folding block is selected. void wxStyledTextCtrl::MarkerSetBackgroundSelected(int markerNumber, const wxColour& back) { + if ( m_mirrorCtrl ) + m_mirrorCtrl->MarkerSetBackgroundSelected(markerNumber, back); SendMsg(SCI_MARKERSETBACKSELECTED, markerNumber, wxColourAsLong(back)); } // Enable/disable highlight for current folding block (smallest one that contains the caret) void wxStyledTextCtrl::MarkerEnableHighlight(bool enabled) { + if ( m_mirrorCtrl ) + m_mirrorCtrl->MarkerEnableHighlight(enabled); SendMsg(SCI_MARKERENABLEHIGHLIGHT, enabled, 0); } // Add a marker to a line, returning an ID which can be used to find or delete the marker. int wxStyledTextCtrl::MarkerAdd(int line, int markerNumber) { + if ( m_mirrorCtrl ) + m_mirrorCtrl->MarkerAdd(line, markerNumber); return SendMsg(SCI_MARKERADD, line, markerNumber); } // Delete a marker from a line. void wxStyledTextCtrl::MarkerDelete(int line, int markerNumber) { + if ( m_mirrorCtrl ) + m_mirrorCtrl->MarkerDelete(line, markerNumber); SendMsg(SCI_MARKERDELETE, line, markerNumber); } // Delete all markers with a particular number from all lines. void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber) { + if ( m_mirrorCtrl ) + m_mirrorCtrl->MarkerDeleteAll(markerNumber); SendMsg(SCI_MARKERDELETEALL, markerNumber, 0); } @@ -686,18 +702,24 @@ int wxStyledTextCtrl::MarkerPrevious(int lineStart, int markerMask) // Define a marker from a bitmap void wxStyledTextCtrl::MarkerDefinePixmap(int markerNumber, const char* const* xpmData) { - SendMsg(SCI_MARKERDEFINEPIXMAP, markerNumber, (sptr_t)xpmData); + if ( m_mirrorCtrl ) + m_mirrorCtrl->MarkerDefinePixmap(markerNumber, xpmData); + SendMsg(SCI_MARKERDEFINEPIXMAP, markerNumber, (sptr_t)xpmData); } // Add a set of markers to a line. void wxStyledTextCtrl::MarkerAddSet(int line, int markerSet) { + if ( m_mirrorCtrl ) + m_mirrorCtrl->MarkerAddSet(line, markerSet); SendMsg(SCI_MARKERADDSET, line, markerSet); } // Set the alpha used for a marker that is drawn in the text area, not the margin. void wxStyledTextCtrl::MarkerSetAlpha(int markerNumber, int alpha) { + if ( m_mirrorCtrl ) + m_mirrorCtrl->MarkerSetAlpha(markerNumber, alpha); SendMsg(SCI_MARKERSETALPHA, markerNumber, alpha); } @@ -2215,8 +2237,8 @@ void wxStyledTextCtrl::SetFoldLevel(int line, int level) { SendMsg(SCI_SETFOLDLEVEL, line, level); - if ( m_mirrorFoldingCtrl ) - m_mirrorFoldingCtrl->SetFoldLevel(line, level); + if ( m_mirrorCtrl ) + m_mirrorCtrl->SetFoldLevel(line, level); } // Retrieve the fold level of a line. @@ -2266,8 +2288,8 @@ void wxStyledTextCtrl::SetFoldExpanded(int line, bool expanded) { SendMsg(SCI_SETFOLDEXPANDED, line, expanded); - if ( m_mirrorFoldingCtrl ) - m_mirrorFoldingCtrl->SetFoldExpanded(line, expanded); + if ( m_mirrorCtrl ) + m_mirrorCtrl->SetFoldExpanded(line, expanded); } // Is a header line expanded? @@ -2281,8 +2303,8 @@ void wxStyledTextCtrl::ToggleFold(int line) { SendMsg(SCI_TOGGLEFOLD, line, 0); - if ( m_mirrorFoldingCtrl ) - m_mirrorFoldingCtrl->ToggleFold(line); + if ( m_mirrorCtrl ) + m_mirrorCtrl->ToggleFold(line); } // Switch a header line between expanded and contracted and show some text after the line. @@ -2290,8 +2312,8 @@ void wxStyledTextCtrl::ToggleFoldShowText(int line, const wxString& text) { SendMsg(SCI_TOGGLEFOLDSHOWTEXT, line, (sptr_t)(const char*)wx2stc(text)); - if ( m_mirrorFoldingCtrl ) - m_mirrorFoldingCtrl->ToggleFoldShowText(line, text); + if ( m_mirrorCtrl ) + m_mirrorCtrl->ToggleFoldShowText(line, text); } // Set the style of fold display text. @@ -2328,8 +2350,8 @@ void wxStyledTextCtrl::FoldLine(int line, int action) { SendMsg(SCI_FOLDLINE, line, action); - if ( m_mirrorFoldingCtrl ) - m_mirrorFoldingCtrl->FoldLine(line, action); + if ( m_mirrorCtrl ) + m_mirrorCtrl->FoldLine(line, action); } // Expand or contract a fold header and its children. @@ -2337,8 +2359,8 @@ void wxStyledTextCtrl::FoldChildren(int line, int action) { SendMsg(SCI_FOLDCHILDREN, line, action); - if ( m_mirrorFoldingCtrl ) - m_mirrorFoldingCtrl->FoldChildren(line, action); + if ( m_mirrorCtrl ) + m_mirrorCtrl->FoldChildren(line, action); } // Expand a fold header and all children. Use the level argument instead of the line's current level. @@ -2352,8 +2374,8 @@ void wxStyledTextCtrl::FoldAll(int action) { SendMsg(SCI_FOLDALL, action, 0); - if ( m_mirrorFoldingCtrl ) - m_mirrorFoldingCtrl->FoldAll(action); + if ( m_mirrorCtrl ) + m_mirrorCtrl->FoldAll(action); } // Ensure a particular line is visible by expanding any header line hiding it. @@ -2379,8 +2401,8 @@ void wxStyledTextCtrl::SetFoldFlags(int flags) { SendMsg(SCI_SETFOLDFLAGS, flags, 0); - if ( m_mirrorFoldingCtrl ) - m_mirrorFoldingCtrl->SetFoldFlags(flags); + if ( m_mirrorCtrl ) + m_mirrorCtrl->SetFoldFlags(flags); } // Ensure a particular line is visible by expanding any header line hiding it. @@ -5479,14 +5501,14 @@ int wxStyledTextCtrl::ReplaceTargetRERaw(const char* text, int length) return SendMsg(SCI_REPLACETARGETRE, length, reinterpret_cast<sptr_t>(text)); } -void wxStyledTextCtrl::SetMirrorFoldingCtrl(wxStyledTextCtrl* mirrorFoldingCtrl) +void wxStyledTextCtrl::SetMirrorCtrl(wxStyledTextCtrl* mirrorCtrl) { - m_mirrorFoldingCtrl = mirrorFoldingCtrl; + m_mirrorCtrl = mirrorCtrl; // Set the fold flags to the same value as in this control in case they had // been changed before calling this function. - if ( m_mirrorFoldingCtrl ) - m_mirrorFoldingCtrl->SetFoldFlags(m_swx->foldFlags); + if ( m_mirrorCtrl ) + m_mirrorCtrl->SetFoldFlags(m_swx->foldFlags); } #if WXWIN_COMPATIBILITY_3_0
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
BTW, there is a small drawing glitch on Windows 11: If you scroll the "Document Map" using the scrollbar, the gray area has some drawing artifacts. Clicking anywhere in the minimap demo, fixes this. Probably a missing "Refresh" call after scrolling is over.
See attached screenshot.
minimap-drawing-glitches.png (view on web)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
BTW, there is a small drawing glitch on Windows 11: If you scroll the "Document Map" using the scrollbar, the gray area has some drawing artifacts.
Just to confirm: this is with the latest state of this branch, including c39b5d9? Because it was supposed to fix exactly this (and did, in my testing...).
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
I am missing this commit (I applied this patch locally by applying: https://github.com/wxWidgets/wxWidgets/pull/25887.diff and this was done before you added that commit).
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Actually, looking at your patch, you definitely don't have this commit in your tree (because it doesn't apply to the header with this change), please get the latest branch and the refresh problem should go away.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
It works.
Below is a diff of the changes I did.
Thanks for checking, but the diff can't be used as is, unfortunately: it modifies generated files and so the changes will be lost the next time src/stc/gen_iface.py is run.
The straightforward way of doing it properly would be to modify this script to add the custom function definitions to it just as I did for folding, but looking at the number of functions, it doesn't seem very appealing, so I think that it would be better to let the script know about the mirrored functions in some way, so that it could add mirroring code automatically. I don't have time to do it right now, but I'll try to do it later if nobody else beats me to it.
Also, it's not great that all the markers defined before establishing the mirror relationship have to be manually applied to the map. Could we use MarkerNext() to get all the existing markers and apply them automatically? If not, we at least need to document this carefully.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Also, it's not great that all the markers defined before establishing the mirror relationship have to be manually applied to the map. Could we use MarkerNext() to get all the existing markers and apply them automatically? If not, we at least need to document this carefully
We should also need to "copy" all the marker definitions as well.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
@vadz pushed 2 commits.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
@vadz pushed 3 commits.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
@eranif Please check if 9d75245 works for you.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
@vadz pushed 1 commit.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
@vadz pushed 4 commits.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
@vadz pushed 2 commits.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Merged #25887 into master.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()