-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathEditor.h
More file actions
137 lines (100 loc) · 3.1 KB
/
Editor.h
File metadata and controls
137 lines (100 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
* Copyright 2014-2018 Kacper Kasper <kacperkasper@gmail.com>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef EDITOR_H
#define EDITOR_H
#include <Message.h>
#include <ScintillaView.h>
#include <SciLexer.h>
#include <memory>
#include <string>
#include <vector>
#include "ScintillaUtils.h"
namespace editor {
class StatusView;
}
enum {
EDITOR_SAVEPOINT_LEFT = 'svpl',
EDITOR_SAVEPOINT_REACHED = 'svpr',
EDITOR_MODIFIED = 'modi',
EDITOR_CONTEXT_MENU = 'conm',
EDITOR_UPDATEUI = 'updu'
};
class Editor : public BScintillaView {
public:
enum Margin {
NUMBER = 0,
FOLD,
BOOKMARKS
};
enum Marker {
BOOKMARK = 0
};
enum Indicator {
WHITESPACE = 0
};
Editor();
virtual void DoLayout();
virtual void FrameResized(float width, float height);
void NotificationReceived(SCNotification* notification);
void ContextMenu(BPoint point);
void SetType(std::string type);
void SetRef(const entry_ref& ref);
void SetReadOnly(bool readOnly);
void CommentLine(Scintilla::Range range);
void CommentBlock(Scintilla::Range range);
void SetCommentLineToken(std::string token);
void SetCommentBlockTokens(std::string start, std::string end);
bool CanCommentLine();
bool CanCommentBlock();
void HighlightTrailingWhitespace();
void ClearHighlightedWhitespace();
void TrimTrailingWhitespace();
void AppendNLAtTheEndIfNotPresent();
void UpdateLineNumberWidth();
void GoToLine(int64 line);
void SetBookmarks(const BMessage &lines);
BMessage Bookmarks();
BMessage BookmarksWithText();
bool ToggleBookmark(int64 line = -1);
void GoToNextBookmark();
void GoToPreviousBookmark();
void SetNumberMarginEnabled(bool enabled);
void SetFoldMarginEnabled(bool enabled);
void SetBookmarkMarginEnabled(bool enabled);
void SetBracesHighlightingEnabled(bool enabled);
void SetBoldFoldMarkersEnabled(bool enabled);
void SetTrailingWSHighlightingEnabled(bool enabled);
std::string SelectionText();
template<typename T>
typename T::type Get() { return T::Get(this); }
template<typename T>
void Set(typename T::type value) { T::Set(this, value); }
private:
void _MaintainIndentation(char ch);
void _UpdateStatusView();
void _BraceHighlight();
bool _BraceMatch(int pos);
void _MarginClick(int margin, int pos);
void _HighlightTrailingWhitespace(Sci_Position start, Sci_Position end);
std::string _LineFeedString(int eolMode);
void _SetLineIndentation(int line, int indent);
editor::StatusView* fStatusView;
std::string fCommentLineToken;
std::string fCommentBlockStartToken;
std::string fCommentBlockEndToken;
Sci_Position fHighlightedWhitespaceStart;
Sci_Position fHighlightedWhitespaceEnd;
Sci_Position fHighlightedWhitespaceCurrentPos;
bool fNumberMarginEnabled;
bool fFoldMarginEnabled;
bool fBookmarkMarginEnabled;
bool fBracesHighlightingEnabled;
bool fBoldFoldMarkersEnabled;
bool fTrailingWSHighlightingEnabled;
// needed for StatusView
std::string fType;
bool fReadOnly;
};
#endif // EDITOR_H