-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcodeedit.h
More file actions
180 lines (137 loc) · 4.84 KB
/
Copy pathcodeedit.h
File metadata and controls
180 lines (137 loc) · 4.84 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#pragma once
#include "brokenstatemenu.h"
#include "linenumbers.h"
#include "listbox.h"
#include "textedit.h"
#include "widget.h"
#include <GLFW/glfw3.h>
#include "application.h"
#include "checkbox.h"
#include <atomic>
#include <filesystem>
#include <mutex>
#include <thread>
struct Position {
int line;
int character;
};
struct Range {
Position start;
Position end;
};
struct EditDoc {
Range range;
std::string newText;
};
struct FileEdit {
std::string uri;
std::vector<EditDoc> edits;
};
struct EditSection {
int startLine, startChar;
int endLine, endChar;
std::string newText;
};
class CodeEdit : public Widget {
public:
CodeEdit(Widget* parent, int tabid, App::PosFunction positioner, App::UpdateFInfoFunction fupdater);
int TABID;
std::atomic<bool> is_loading{false};
App::PosFunction POS_FUNC = nullptr;
App::UpdateFInfoFunction FUPDATER = nullptr;
int timeuntil = -1;
// int timeuntilchauffeur = -1;
TextEdit* textedit;
LineNumbers* line_numbers;
Highlighter* highlighter = nullptr;
std::thread hoverthread;
// std::thread chauffeurthread;
static int indentIdentifierAfterLine(icu::UnicodeString line, icu::UnicodeString nextline);
int completion_id = -1;
int goto_id = -1;
int hover_id = -1;
bool should_move_mouse_hover = false;
int code_actions_id = -1;
int rename_id = -1;
bool rounded = true;
TextEdit* renamebox = nullptr;
Cursor renamecursor = Cursor();
std::vector<std::string> completions = {};
std::vector<int> errorlines = {};
ListBox* completionbox;
bool are_code_actions = false;
// bool is_chauffeur = false;
std::vector<json> code_actions = {};
ListBox* errorMenu;
std::filesystem::file_time_type last_file_mod_time = {};
bool on_key_event(int key, int scancode, int action, int mods);
bool on_char_event(unsigned int keycode);
bool on_mouse_button_event(int button, int action, int mods);
bool on_mouse_move_event();
bool on_scroll_event(double xchange, double ychange);
void executeAction(WidgetActionType typ);
bool hoveringHoverbox(int mx, int my, int padding = 0);
bool hoveringCompletionBox(int mx, int my, int padding = 0);
int last_mouse_x = -1;
int last_mouse_y = -1;
FileInfo* file = nullptr;
std::string language = "";
std::string lsp = "";
void detectLanguage();
TextEdit* hoverbox = nullptr;
Cursor hoverCrsr = Cursor();
LineResult highlightline(icu::UnicodeString line, TextMateInfo info);
void position(int x, int y, int w, int h);
void render();
void renderExtras();
void renderFindBox();
void triggerSaveAs();
void openFile(FileInfo* f);
void save();
bool was_in_a_file = false;
bool FILE_BROKEN_STATE = false;
BrokenStateMenu* broken_state_menu = nullptr;
bool REQUESTING_FIXIT = false;
BrokenStateMenu* fixit_request_menu = nullptr;
void overwrite_file();
void reload_file();
bool find_menu_open = false;
TextEdit* findTextEdit = nullptr;
TextEdit* replaceTextEdit = nullptr;
CheckBox* caseSensitivity = nullptr;
Button* prevButton = nullptr;
Button* nextButton = nullptr;
Button* nextReplButton = nullptr;
Button* allButton = nullptr;
Button* showErrorsButton = nullptr;
bool madeChangeBetweenSaves = false;
std::mutex saving_lock;
void activateCompletion();
void activateFind(bool forwards, icu::UnicodeString tofind, bool case_sensitive);
void activateReplace(bool forwards, icu::UnicodeString tofind, icu::UnicodeString replace, bool case_sensitive);
void replaceAll(icu::UnicodeString tofind, icu::UnicodeString toreplace, bool case_sensitive);
void run_fixit();
void undo_fixit();
int analyzeForFixit_on_lines(const std::vector<Line>&);
void completionRecieved(std::vector<std::string> completions, int id);
void publishDiagnostics(std::string file, std::vector<std::string> messages, std::vector<int> startC, std::vector<int> startL, std::vector<int> endC, std::vector<int> endL, std::vector<int> severities);
void onTextChanged(Widget* w);
void gotoerror(int errnum);
void gotoDef(int id, int line1, int character1, int line, int character, std::string locURI);
void hoverRecieved(std::string content, std::string type, int id);
void showhideerrors();
void actionsReceived(int id, json resp);
void renameReceived(int id, json resp);
std::vector<FileEdit> parseCommandArguments(const json& changesObj);
std::vector<FileEdit> parseWorkspaceEdits(const json& docChangesArr);
std::vector<FileEdit> parseCodeAction(const json& action);
std::vector<std::string> splitLines(const std::string& s);
void applyEditToLines(std::vector<std::string>& lines, const EditDoc& te);
void applyOtherFileEdits(const std::vector<FileEdit>& edits, const std::string& currentFilePath);
std::vector<EditSection> gatherCurrentFileSections(const std::vector<FileEdit>& edits, const std::string& currentFilePath);
std::string augmentBuildCommand(std::string inital);
void setComments();
void removeComments();
int DO_RENDER = 3;
private:
};