-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditor.hpp
More file actions
57 lines (49 loc) · 1.32 KB
/
editor.hpp
File metadata and controls
57 lines (49 loc) · 1.32 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
#pragma once
#include <text-editor/app.hpp>
#include <tvision/tv.h>
#include <scintilla.h>
#include <scintilla/tscintilla.h>
#include <set>
#include <string>
enum class Language : uint8_t {
None,
CPP,
Python,
JSON,
Bash,
Pascal
};
struct EditorObserver{
public:
virtual void editorUpdate() = 0;
};
struct Editor : turbo::TScintillaParent{
public:
Editor();
void setSize(const TPoint& size);
void paint(TDrawSurface& surface, TRect area);
void handleEvent(TEvent &event);
TPoint pointMainCaret();
//observers
void addObserver(EditorObserver* observer);
void removeObserver(EditorObserver* observer);
//interface TScintillaParent
virtual TPoint getEditorSize() noexcept;
virtual void invalidate(TRect area) noexcept;
virtual void handleNotification(const SCNotification &scn);
virtual void setVerticalScrollPos(int delta, int limit) noexcept;
virtual void setHorizontalScrollPos(int delta, int limit) noexcept;
//file manipulation
void openFile(const std::string& path);
void readFile();
void saveFile();
bool isModified();
private:
void updateAll();
void configureStyling(Language language);
private:
std::string path;
turbo::TScintilla scintilla;
TPoint size = {0, 0};
std::set<EditorObserver*> observers;
};