Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

FixedLine uses the BracketHighlight directly, instead of the interval.

  • Loading branch information...
commit 25e38f5190c40ea82f509e450a460db391ded295 1 parent b488c1e
@adamv adamv authored
View
3  src/BracketHighlight.h
@@ -21,6 +21,9 @@ class BracketHighlight {
bool UpdateIfChanged(unsigned int changeToken, unsigned int pos);
+ unsigned int Start() const {return m_interval.start;};
+ unsigned int End() const {return m_interval.end;};
+
private:
interval m_interval; // Interval for the current bracket pair.
unsigned int m_lastChangeToken;
View
2  src/EditorCtrl.cpp
@@ -5172,7 +5172,7 @@ search_result EditorCtrl::RawRegexSearch(const char* regex, unsigned int subject
wxASSERT(regex);
wxASSERT(subjectStart <= subjectEnd);
wxASSERT(subjectEnd <= GetLength());
- wxASSERT(pos >= subjectStart && pos <= subjectEnd);
+ wxASSERT(subjectStart <= pos && pos <= subjectEnd);
search_result sr;
View
2  src/EditorCtrl.h
@@ -325,7 +325,7 @@ class EditorCtrl : public KeyHookable<wxControl>,
virtual void GotoSymbolPos(unsigned int pos);
// Bracket Highlighting
- virtual const interval& GetHlBracket() const {return m_bracketHighlight.GetInterval();};
+ virtual const BracketHighlight& GetHlBracket() const {return m_bracketHighlight;};
// Folding
vector<unsigned int> GetFoldedLines() const;
View
7 src/EditorPrintout.cpp
@@ -17,10 +17,11 @@
#include "FixedLine.h"
#include "LineListWrap.h"
#include "Catalyst.h"
+#include "BracketHighlight.h"
// Dummy vars for line
const std::vector<interval> s_sel;
-const interval s_hlBracket(0,0);
+const BracketHighlight s_brackets;
const unsigned int s_lastpos = 0;
const bool s_isShadow = false;
@@ -52,7 +53,7 @@ void EditorPrintout::OnPreparePrinting() {
// Initialize line info
- m_line = new FixedLine(dc, m_printDoc.GetDocument(), s_sel, s_hlBracket, s_lastpos, s_isShadow, m_theme);
+ m_line = new FixedLine(dc, m_printDoc.GetDocument(), s_sel, s_brackets, s_lastpos, s_isShadow, m_theme);
m_line->SetPrintMode();
m_line->Init();
m_line->SetWordWrap(cxWRAP_SMART);
@@ -114,7 +115,7 @@ bool EditorPrintout::OnPrintPage(int pageNum) {
const wxFont& font = m_theme.font;
dc.SetFont(font);
- FixedLine line(dc, m_printDoc.GetDocument(), s_sel, s_hlBracket, s_lastpos, s_isShadow, m_theme);
+ FixedLine line(dc, m_printDoc.GetDocument(), s_sel, s_brackets, s_lastpos, s_isShadow, m_theme);
line.SetPrintMode();
line.Init();
line.SetWordWrap(cxWRAP_SMART);
View
22 src/FixedLine.cpp
@@ -18,11 +18,13 @@
#include "tmTheme.h"
#include "styler.h"
#include "Utf.h"
+#include "BracketHighlight.h"
// Initialize static variables
wxString FixedLine::s_text;
-FixedLine::FixedLine(wxDC& dc, const DocumentWrapper& dw, const vector<interval>& sel, const interval& hlBracket, const unsigned int& lastpos, const bool& isShadow, const tmTheme& theme):
+FixedLine::FixedLine(wxDC& dc, const DocumentWrapper& dw, const vector<interval>& sel, const BracketHighlight& brackets,
+ const unsigned int& lastpos, const bool& isShadow, const tmTheme& theme):
dc((FastDC&)dc),
m_doc(dw),
textstart(0), textend(0),
@@ -32,7 +34,7 @@ FixedLine::FixedLine(wxDC& dc, const DocumentWrapper& dw, const vector<interval>
lastpos(lastpos),
m_isSelShadow(isShadow),
selections(sel),
- m_hlBracket(hlBracket),
+ m_brackets(brackets),
m_theme(theme),
m_sr(m_theme, (FastDC&)dc),
m_wrapMode(cxWRAP_NONE),
@@ -315,7 +317,7 @@ void FixedLine::SetTabWidth(unsigned int tabChars) {
tabwidth = tabChars * charwidth;
m_tabChars = tabChars;
- // Draw hidden tab
+ // Draw hidden tab arrow
bmTab = wxBitmap(tabwidth, charheight, 1);
wxMemoryDC mdc;
mdc.SelectObject(bmTab);
@@ -463,14 +465,14 @@ void FixedLine::DrawLine(int xoffset, int yoffset, const wxRect& WXUNUSED(rect),
}
// Highlight matching brackets (can only be single byte utf char)
- if (m_hlBracket.start < m_hlBracket.end) {
- if (m_hlBracket.start >= textstart && m_hlBracket.start < textend) {
- m_sr.SetFontStyle(m_hlBracket.start, m_hlBracket.start+1, wxFONTFLAG_BOLD);
- m_sr.SetBackgroundColor(m_hlBracket.start, m_hlBracket.start+1, m_theme.bracketHighlightColor);
+ if (m_brackets.HasOrderedInterval()) {
+ if (textstart <= m_brackets.Start() && m_brackets.Start() < textend) {
+ m_sr.SetFontStyle(m_brackets.Start(), m_brackets.Start()+1, wxFONTFLAG_BOLD);
+ m_sr.SetBackgroundColor(m_brackets.Start(), m_brackets.Start()+1, m_theme.bracketHighlightColor);
}
- if (m_hlBracket.end >= textstart && m_hlBracket.end < textend) {
- m_sr.SetFontStyle(m_hlBracket.end, m_hlBracket.end+1, wxFONTFLAG_BOLD);
- m_sr.SetBackgroundColor(m_hlBracket.end, m_hlBracket.end+1, m_theme.bracketHighlightColor);
+ if (textstart <= m_brackets.End() && m_brackets.End() < textend) {
+ m_sr.SetFontStyle(m_brackets.End(), m_brackets.End()+1, wxFONTFLAG_BOLD);
+ m_sr.SetBackgroundColor(m_brackets.End(), m_brackets.End()+1, m_theme.bracketHighlightColor);
}
}
View
46 src/FixedLine.h
@@ -27,6 +27,7 @@ class FastDC;
struct tmTheme;
class Styler;
class DocumentWrapper;
+class BracketHighlight;
struct full_pos {
int pos;
@@ -38,7 +39,7 @@ struct full_pos {
class FixedLine {
public:
- FixedLine(wxDC& dc, const DocumentWrapper& dw, const vector<interval>& sel, const interval& hlBracket, const unsigned int& lastpos, const bool& isShadow, const tmTheme& theme);
+ FixedLine(wxDC& dc, const DocumentWrapper& dw, const vector<interval>& sel, const BracketHighlight& brackets, const unsigned int& lastpos, const bool& isShadow, const tmTheme& theme);
void Init();
bool IsValid() const {return width != 0;};
@@ -90,50 +91,49 @@ class FixedLine {
// Member variables
FastDC& dc;
const DocumentWrapper& m_doc;
- unsigned int m_docLen;
unsigned int textstart;
unsigned int textend;
unsigned int m_lineLen;
- wxCharBuffer m_lineBuffer;
unsigned int m_lineBufferLen;
+ int width;
+ int old_width;
+ unsigned int m_tabChars;
+ const unsigned int& lastpos;
+ const bool& m_isSelShadow;
+ const BracketHighlight& m_brackets;
+ const tmTheme& m_theme;
+ StyleRun m_sr;
+ unsigned int m_docLen;
+ wxCharBuffer m_lineBuffer;
unsigned int m_lineWidth; // full width when no word-wrap
wxString m_textBuf;
vector<unsigned int> m_extents;
wxArrayInt m_extsBuf;
- int width;
int height;
- int old_width;
int charwidth;
int m_nlwidth;
int charheight;
int tabwidth;
- unsigned int m_tabChars;
- const unsigned int& lastpos;
- const bool& m_isSelShadow;
const vector<interval>& selections;
- const interval& m_hlBracket;
- vector<unsigned int> breakpoints;
- vector<Styler*> m_stylers;
- const tmTheme& m_theme;
- StyleRun m_sr;
- bool m_isFontFixedWidth;
-
- // Settings
cxWrapMode m_wrapMode;
bool m_showIndent;
-
- // Smart wrap
unsigned int m_indentWidth;
-
- // Folding
wxBitmap bmFold;
- unsigned int m_foldWidth;
- unsigned int m_foldHeight;
-
wxBitmap bmNewline;
wxBitmap bmSpace;
wxBitmap bmTab;
+ // Above: set in constructors' intializer list
+ // ----
+ // Below: not set in initializer list
+
+ vector<unsigned int> breakpoints;
+ vector<Styler*> m_stylers;
+ bool m_isFontFixedWidth;
+
+ unsigned int m_foldWidth;
+ unsigned int m_foldHeight;
+
static wxString s_text;
#ifdef __WXDEBUG__
View
5 src/IFoldingEditor.h
@@ -6,6 +6,7 @@
struct cxFold;
class interval;
+class BracketHighlight;
class IFoldingEditor {
public:
@@ -13,10 +14,10 @@ class IFoldingEditor {
virtual void UnFoldParents(unsigned int line_id) = 0;
virtual const std::vector<cxFold>& GetFolds() const = 0;
- // This isn't used by Lines directly, but is passed to internal data member Line.
+ // This isn't used by Lines directly, but is passed to internal data member (Fixed)Line.
// The only pubilc use of this member is in Lines; the underlying EditorCtrl member
// is used internally in the editor control.
- virtual const interval& GetHlBracket() const = 0;
+ virtual const BracketHighlight& GetHlBracket() const = 0;
};
#endif // __IFOLDINGEDITOR_H__
Please sign in to comment.
Something went wrong with that request. Please try again.