Switch to OOP style code
This commit is contained in:
@@ -1,23 +1,22 @@
|
||||
#include "editor/editor.h"
|
||||
#include "main.h"
|
||||
|
||||
Coord editor_hit_test(Editor *editor, uint32_t x, uint32_t y) {
|
||||
Coord Editor::click_coord(uint32_t x, uint32_t y) {
|
||||
if (mode == INSERT)
|
||||
x++;
|
||||
uint32_t numlen =
|
||||
EXTRA_META + static_cast<int>(std::log10(editor->root->line_count + 1));
|
||||
uint32_t render_width = editor->size.col - numlen;
|
||||
EXTRA_META + static_cast<int>(std::log10(this->root->line_count + 1));
|
||||
uint32_t render_width = this->size.col - numlen;
|
||||
x = MAX(x, numlen) - numlen + 1;
|
||||
uint32_t target_visual_row = y;
|
||||
uint32_t visual_row = 0;
|
||||
uint32_t line_index = editor->scroll.row;
|
||||
uint32_t last_line_index = editor->scroll.row;
|
||||
uint32_t last_col = editor->scroll.col;
|
||||
uint32_t line_index = this->scroll.row;
|
||||
uint32_t last_line_index = this->scroll.row;
|
||||
uint32_t last_col = this->scroll.col;
|
||||
bool first_visual_line = true;
|
||||
std::shared_lock knot_lock(editor->knot_mtx);
|
||||
LineIterator *it = begin_l_iter(editor->root, line_index);
|
||||
LineIterator *it = begin_l_iter(this->root, line_index);
|
||||
if (!it)
|
||||
return editor->scroll;
|
||||
return this->scroll;
|
||||
while (visual_row <= target_visual_row) {
|
||||
uint32_t line_len;
|
||||
char *line = next_line(it, &line_len);
|
||||
@@ -27,7 +26,7 @@ Coord editor_hit_test(Editor *editor, uint32_t x, uint32_t y) {
|
||||
line_len--;
|
||||
last_line_index = line_index;
|
||||
last_col = line_len;
|
||||
uint32_t offset = first_visual_line ? editor->scroll.col : 0;
|
||||
uint32_t offset = first_visual_line ? this->scroll.col : 0;
|
||||
first_visual_line = false;
|
||||
while (offset < line_len || (line_len == 0 && offset == 0)) {
|
||||
uint32_t col = 0;
|
||||
|
||||
Reference in New Issue
Block a user