Improve highlighting structure
- switched to a sparse delta based map - true lazy-loading to avoid any unneccessary allocations - fixed windows management api
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
|
||||
void Editor::handle_event(KeyEvent event) {
|
||||
uint8_t old_mode = mode;
|
||||
if (this->hover_active)
|
||||
this->hover_active = false;
|
||||
if (!this->hover_popup->hidden)
|
||||
this->hover_popup->hidden = true;
|
||||
if (event.key_type == KEY_SPECIAL) {
|
||||
switch (event.special_modifier) {
|
||||
case 0:
|
||||
@@ -67,12 +67,12 @@ void Editor::handle_event(KeyEvent event) {
|
||||
this->select_all();
|
||||
break;
|
||||
case CTRL('h'):
|
||||
static_cast<HoverBox *>(ui::hover_popup->tile.get())->scroll(-1);
|
||||
this->hover_active = true;
|
||||
this->hover_popup->scroll(-1);
|
||||
this->hover_popup->hidden = false;
|
||||
break;
|
||||
case CTRL('l'):
|
||||
static_cast<HoverBox *>(ui::hover_popup->tile.get())->scroll(1);
|
||||
this->hover_active = true;
|
||||
this->hover_popup->scroll(1);
|
||||
this->hover_popup->hidden = false;
|
||||
break;
|
||||
case 'h':
|
||||
this->fetch_lsp_hover();
|
||||
|
||||
@@ -410,11 +410,10 @@ void Editor::fetch_lsp_hover() {
|
||||
hover_text += contents.get<std::string>();
|
||||
}
|
||||
if (!hover_text.empty()) {
|
||||
auto hover_box = static_cast<HoverBox *>(ui::hover_popup->tile.get());
|
||||
hover_box->clear();
|
||||
hover_box->text = clean_text(hover_text);
|
||||
hover_box->is_markup = is_markup;
|
||||
message.editor->hover_active = true;
|
||||
message.editor->hover_popup->clear();
|
||||
message.editor->hover_popup->text = clean_text(hover_text);
|
||||
message.editor->hover_popup->is_markup = is_markup;
|
||||
message.editor->hover_popup->hidden = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -423,12 +422,14 @@ void Editor::fetch_lsp_hover() {
|
||||
}
|
||||
|
||||
void Editor::handle_click(KeyEvent event, Coord size) {
|
||||
focused_window = this;
|
||||
layout::focused_window = this;
|
||||
this->size = size;
|
||||
static std::chrono::steady_clock::time_point last_click_time =
|
||||
std::chrono::steady_clock::now();
|
||||
static uint32_t click_count = 0;
|
||||
static Coord last_click_pos = {UINT32_MAX, UINT32_MAX};
|
||||
if (!this->hover_popup->hidden)
|
||||
this->hover_popup->hidden = true;
|
||||
if (event.key_type == KEY_MOUSE) {
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
|
||||
@@ -31,7 +31,7 @@ void Editor::render(std::vector<ScreenCell> &buffer, Coord size, Coord pos) {
|
||||
return (int)token.type;
|
||||
return 0;
|
||||
};
|
||||
Coord screen = get_size();
|
||||
Coord screen = {io::rows, io::cols};
|
||||
auto update = [&](uint32_t row, uint32_t col, std::string text, uint32_t fg,
|
||||
uint32_t bg, uint8_t flags, uint32_t u_color,
|
||||
uint32_t width) {
|
||||
@@ -115,12 +115,8 @@ void Editor::render(std::vector<ScreenCell> &buffer, Coord size, Coord pos) {
|
||||
while (rendered_rows < this->size.row) {
|
||||
uint32_t line_len;
|
||||
char *line = next_line(it, &line_len);
|
||||
if (this->parser) {
|
||||
if (line_data)
|
||||
line_data = this->parser->line_tree.next();
|
||||
else
|
||||
line_data = this->parser->line_tree.start_iter(line_index);
|
||||
}
|
||||
if (this->parser)
|
||||
line_data = this->parser->line_map.at(line_index);
|
||||
if (!line)
|
||||
break;
|
||||
if (line_len > 0 && line[line_len - 1] == '\n')
|
||||
@@ -477,8 +473,8 @@ void Editor::render(std::vector<ScreenCell> &buffer, Coord size, Coord pos) {
|
||||
// this->hover.render(cursor);
|
||||
// else if (this->diagnostics_active)
|
||||
// this->diagnostics.render(cursor);
|
||||
if (this->hover_active)
|
||||
ui::hover_popup->pos = cursor;
|
||||
if (!this->hover_popup->hidden)
|
||||
this->hover_popup->pos = cursor;
|
||||
}
|
||||
free(it->buffer);
|
||||
free(it);
|
||||
|
||||
Reference in New Issue
Block a user