Browse files

Made bookmarked lines show up with a highlighted background.

Made bookmarked lines show up with a highlighted background.

Made bookmarked lines show up with a highlighted background.
  • Loading branch information...
1 parent b04a781 commit b9d6891f14962bb3cd5740ae108f8cbbc58d7632 @ajpalkovic ajpalkovic committed Jun 27, 2010
Showing with 25 additions and 1 deletion.
  1. +7 −0 src/Bookmarks.cpp
  2. +3 −0 src/Bookmarks.h
  3. +6 −0 src/EditorCtrl.cpp
  4. +1 −0 src/EditorCtrl.h
  5. +2 −0 src/IFoldingEditor.h
  6. +6 −1 src/Lines.cpp
  7. 0 src/Lines.h
View
7 src/Bookmarks.cpp 100644 → 100755
@@ -1,6 +1,7 @@
#include "Bookmarks.h"
#include "Catalyst.h"
#include "Lines.h"
+#include <map>
typedef std::vector<cxBookmark>::iterator bookmark_iter;
@@ -145,3 +146,9 @@ void Bookmarks::ApplyChanges(const std::vector<cxChange>& changes) {
p->end = lines.GetLineEndpos(p->line_id);
}
}
+
+void Bookmarks::BuildMap(std::map<int, bool>& bookmarksMap) const {
+ for(unsigned int c = 0; c < bookmarks.size(); c++) {
+ bookmarksMap[bookmarks[c].line_id] = true;
+ }
+}
View
3 src/Bookmarks.h 100644 → 100755
@@ -2,6 +2,7 @@
#define __BOOKMARKS_H__
#include <vector>
+#include <map>
const unsigned int NO_BOOKMARK = (unsigned int)-1;
@@ -32,6 +33,8 @@ class Bookmarks {
void ApplyChanges(const std::vector<cxChange>& changes);
+ void BuildMap(std::map<int, bool>& bookmarksMap) const;
+
private:
std::vector<cxBookmark> bookmarks;
const ILinePositions& lines;
View
6 src/EditorCtrl.cpp 100644 → 100755
@@ -8854,10 +8854,12 @@ void EditorCtrl::ToogleBookmarkOnCurrentLine() {
void EditorCtrl::AddBookmark(unsigned int line_id, bool toggle) {
wxASSERT(line_id < m_lines.GetLineCount());
bookmarks.AddBookmark(line_id, toggle);
+ DrawLayout();
}
void EditorCtrl::DeleteBookmark(unsigned int line_id) {
bookmarks.DeleteBookmark(line_id);
+ DrawLayout();
}
void EditorCtrl::GotoNextBookmark() {
@@ -8878,6 +8880,10 @@ void EditorCtrl::GotoPrevBookmark() {
}
}
+void EditorCtrl::BuildBookmarkMap(std::map<int, bool>& bookmarksMap) const {
+ bookmarks.BuildMap(bookmarksMap);
+}
+
EditorChangeState EditorCtrl::GetChangeState() const {
return EditorChangeState(this->GetId(), this->GetChangeToken());
}
View
1 src/EditorCtrl.h 100644 → 100755
@@ -361,6 +361,7 @@ class EditorCtrl : public KeyHookable<wxControl>,
void GotoNextBookmark();
void GotoPrevBookmark();
const vector<cxBookmark>& GetBookmarks() const;
+ void BuildBookmarkMap(std::map<int, bool>& bookmarksMap) const;
// Scroll Position
int GetYScrollPos() const { return scrollPos; };
View
2 src/IFoldingEditor.h 100644 → 100755
@@ -4,6 +4,7 @@
#include <wx/platform.h>
#include <vector>
+struct ckBookmark;
struct cxFold;
class interval;
class BracketHighlight;
@@ -18,6 +19,7 @@ class IFoldingEditor {
// The only pubilc use of this member is in Lines; the underlying EditorCtrl member
// is used internally in the editor control.
virtual const BracketHighlight& GetHlBracket() const = 0;
+ virtual void BuildBookmarkMap(std::map<int, bool>& bookmarksMap) const = 0;
};
#endif // __IFOLDINGEDITOR_H__
View
7 src/Lines.cpp 100644 → 100755
@@ -19,6 +19,7 @@
#include "tmTheme.h"
#include <wx/filename.h>
#include "styler.h"
+#include <map>
Lines::Lines(wxDC& dc, DocumentWrapper& dw, IFoldingEditor& editorCtrl, const tmTheme& theme):
dc(dc),
@@ -1003,6 +1004,10 @@ void Lines::Draw(int xoffset, int yoffset, wxRect& rect) {
dc.DrawRectangle(0, FoldedYPos(ll->height()) + yoffset, rect.width, line.GetCharHeight());
}
+ //Build a map of the bookmarks for constant time access
+ std::map<int, bool> bookmarksMap;
+ m_editorCtrl.BuildBookmarkMap(bookmarksMap);
+
if (top_ypos < height) {
// Get the first visible line
unsigned int firstline = ll->find_ypos(top_ypos);
@@ -1019,7 +1024,7 @@ void Lines::Draw(int xoffset, int yoffset, wxRect& rect) {
SetLine(firstline);
// Check if we should highlight the line background
- if (firstline == currentLine) {
+ if (firstline == currentLine || bookmarksMap.find(firstline) != bookmarksMap.end()) {
dc.SetBrush(wxBrush(m_theme.lineHighlightColor));
dc.SetPen(wxPen(m_theme.lineHighlightColor));
View
0 src/Lines.h 100644 → 100755
File mode changed.

0 comments on commit b9d6891

Please sign in to comment.