diff options
-rw-r--r-- | doc/ScintillaDoc.html | 7 | ||||
-rw-r--r-- | doc/ScintillaHistory.html | 6 | ||||
-rw-r--r-- | include/Scintilla.h | 1 | ||||
-rw-r--r-- | include/Scintilla.iface | 3 | ||||
-rw-r--r-- | src/Editor.cxx | 25 | ||||
-rw-r--r-- | test/simpleTests.py | 40 |
6 files changed, 77 insertions, 5 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 1a07a4032..feab651ee 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -6801,6 +6801,8 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ <br /> <a class="message" href="#SCI_MULTIEDGEADDLINE">SCI_MULTIEDGEADDLINE(position column, colour edgeColour)</a><br /> <a class="message" href="#SCI_MULTIEDGECLEARALL">SCI_MULTIEDGECLEARALL</a><br /> + <a class="message" href="#SCI_GETMULTIEDGECOLUMN">SCI_GETMULTIEDGECOLUMN(int which)</a> + <br /> </code> <p><b id="SCI_SETEDGEMODE">SCI_SETEDGEMODE(int edgeMode)</b><br /> @@ -6878,10 +6880,13 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ <p><b id="SCI_MULTIEDGEADDLINE">SCI_MULTIEDGEADDLINE(position column, <a class="jump" href="#colour">colour</a> edgeColour)</b><br /> <b id="SCI_MULTIEDGECLEARALL">SCI_MULTIEDGECLEARALL</b><br /> + <b id="SCI_GETMULTIEDGECOLUMN">SCI_GETMULTIEDGECOLUMN(int which)</b><br /> <code>SCI_MULTIEDGEADDLINE</code> adds a new vertical edge to the view. The edge will be displayed at the given column number. The resulting edge position depends on the metric of a space character in <code>STYLE_DEFAULT</code>. All the edges can be cleared with - <code>SCI_MULTIEDGECLEARALL</code>.</p> + <code>SCI_MULTIEDGECLEARALL</code>. <code>SCI_GETMULTIEDGECOLUMN</code> returns the column of the + Nth vertical edge (indexed from 0). If <code class="parameter">which</code> is greater or equal + to the number of vertical edges, this returns -1.</p> <h2 id="Accessibility">Accessibility</h2> diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 8ab756144..c0eb117a7 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -550,6 +550,8 @@ <td>Hugues Larrive</td> <td>Prakash Sahni</td> <td>uhf7</td> + </tr><tr> + <td>Derek Brown</td> </tr> </table> <p> @@ -597,6 +599,10 @@ Fixed bug where layout caching was ineffective. <a href="https://sourceforge.net/p/scintilla/bugs/2197/">Bug #2197</a>. </li> + <li> + Added method for iterating through multiple vertical edges: SCI_GETMULTIEDGECOLUMN. + <a href="https://sourceforge.net/p/scintilla/feature-requests/1350/">Feature #1350</a>. + </li> </ul> <h3> <a href="https://sourceforge.net/projects/scintilla/files/scintilla/3.21.0/scintilla3210.zip/download">Release 3.21.0</a> diff --git a/include/Scintilla.h b/include/Scintilla.h index 32012c5f6..6f59d4e27 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -705,6 +705,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETEDGECOLOUR 2365 #define SCI_MULTIEDGEADDLINE 2694 #define SCI_MULTIEDGECLEARALL 2695 +#define SCI_GETMULTIEDGECOLUMN 2749 #define SCI_SEARCHANCHOR 2366 #define SCI_SEARCHNEXT 2367 #define SCI_SEARCHPREV 2368 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index fb31e5b73..7d32ed46d 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -1935,6 +1935,9 @@ fun void MultiEdgeAddLine=2694(position column, colour edgeColour) # Clear all vertical edges. fun void MultiEdgeClearAll=2695(,) +# Get multi edge positions. +get position GetMultiEdgeColumn=2749(int which,) + # Sets the current caret position to be the search anchor. fun void SearchAnchor=2366(,) diff --git a/src/Editor.cxx b/src/Editor.cxx index 4256bb817..8453118b3 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -7690,16 +7690,33 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { InvalidateStyleRedraw(); break; - case SCI_MULTIEDGEADDLINE: - vs.theMultiEdge.push_back(EdgeProperties(wParam, lParam)); - InvalidateStyleRedraw(); - break; + case SCI_MULTIEDGEADDLINE: { + // Insert new edge in sorted order. + const int column = static_cast<int>(wParam); + vs.theMultiEdge.insert( + std::upper_bound(vs.theMultiEdge.begin(), vs.theMultiEdge.end(), column, + [](const EdgeProperties &a, const EdgeProperties &b) { + return a.column < b.column; + }), + EdgeProperties(wParam, lParam)); + InvalidateStyleRedraw(); + break; + } case SCI_MULTIEDGECLEARALL: std::vector<EdgeProperties>().swap(vs.theMultiEdge); // Free vector and memory, C++03 compatible InvalidateStyleRedraw(); break; + case SCI_GETMULTIEDGECOLUMN: { + const size_t which = wParam; + // size_t is unsigned so this also handles negative inputs. + if (which >= vs.theMultiEdge.size()) { + return -1; + } + return vs.theMultiEdge[which].column; + } + case SCI_GETACCESSIBILITY: return SC_ACCESSIBILITY_DISABLED; diff --git a/test/simpleTests.py b/test/simpleTests.py index 7b4bfcaf2..0e39ec55d 100644 --- a/test/simpleTests.py +++ b/test/simpleTests.py @@ -2318,6 +2318,46 @@ class TestCallTip(unittest.TestCase): self.ed.CallTipCancel() self.assertEquals(self.ed.CallTipActive(), 0) +class TestEdge(unittest.TestCase): + + def setUp(self): + self.xite = Xite.xiteFrame + self.ed = self.xite.ed + self.ed.ClearAll() + + def testBasics(self): + self.ed.EdgeColumn = 3 + self.assertEquals(self.ed.EdgeColumn, 3) + self.ed.SetEdgeColour(0xA0) + self.assertEquals(self.ed.GetEdgeColour(), 0xA0) + + def testMulti(self): + self.assertEquals(self.ed.GetMultiEdgeColumn(-1), -1) + self.assertEquals(self.ed.GetMultiEdgeColumn(0), -1) + self.ed.MultiEdgeAddLine(5, 0x50) + self.assertEquals(self.ed.GetMultiEdgeColumn(0), 5) + self.assertEquals(self.ed.GetMultiEdgeColumn(1), -1) + self.ed.MultiEdgeAddLine(6, 0x60) + self.assertEquals(self.ed.GetMultiEdgeColumn(0), 5) + self.assertEquals(self.ed.GetMultiEdgeColumn(1), 6) + self.assertEquals(self.ed.GetMultiEdgeColumn(2), -1) + self.ed.MultiEdgeAddLine(4, 0x40) + self.assertEquals(self.ed.GetMultiEdgeColumn(0), 4) + self.assertEquals(self.ed.GetMultiEdgeColumn(1), 5) + self.assertEquals(self.ed.GetMultiEdgeColumn(2), 6) + self.assertEquals(self.ed.GetMultiEdgeColumn(3), -1) + self.ed.MultiEdgeClearAll() + self.assertEquals(self.ed.GetMultiEdgeColumn(0), -1) + + def testSameTwice(self): + # Tests that adding a column twice retains both + self.ed.MultiEdgeAddLine(5, 0x50) + self.ed.MultiEdgeAddLine(5, 0x55) + self.assertEquals(self.ed.GetMultiEdgeColumn(0), 5) + self.assertEquals(self.ed.GetMultiEdgeColumn(1), 5) + self.assertEquals(self.ed.GetMultiEdgeColumn(2), -1) + self.ed.MultiEdgeClearAll() + class TestAutoComplete(unittest.TestCase): def setUp(self): |