Skip to content

Commit 538e060

Browse files
committed
[fix] box cursor rendering and selection
1 parent 230c2ee commit 538e060

File tree

5 files changed

+256
-305
lines changed

5 files changed

+256
-305
lines changed

include/ekg/io/utf.hpp

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -103,24 +103,9 @@ namespace ekg {
103103
std::string_view string
104104
);
105105

106-
/**
107-
* Fast splitter specialized in `\n` or `\r\n` (non OS unix-based).
108-
* UTF to sinalize the string unicode-like suggested by EKG.
109-
*/
110-
void utf8_split_new_line(
111-
std::string_view string,
112-
std::vector<std::string> &utf8_split_new_lined
113-
);
114-
115-
/**
116-
* Return true if `string` contains `find_char`,
117-
* then it must allocate and insert elements to
118-
* `p_string_split_list` ptr.
119-
*/
120-
bool utf8_split(
121-
std::vector<std::string> &string_split_list,
122-
const std::string &string,
123-
char find_char
106+
size_t utf8_split_endings(
107+
std::string_view line,
108+
std::vector<std::string> &splitted
124109
);
125110

126111
template<typename t>
@@ -151,41 +136,46 @@ namespace ekg {
151136
protected:
152137
std::vector<ekg::io::chunk_t> loaded_chunks {};
153138
size_t lines_per_chunk_limit {10};
139+
size_t total_lines {};
154140
size_t total_chars {};
141+
size_t prev_lines {};
155142
size_t prev_total_chars {};
143+
156144
bool was_audited {};
157145
bool should_count {};
146+
protected:
147+
void swizzle(
148+
size_t chunk_index,
149+
size_t line_index,
150+
std::vector<std::string> &to_swizzle,
151+
bool skip_first_line
152+
);
158153
public:
159-
static std::string line_not_found;
160-
public:
161-
std::string read(size_t index);
162-
std::string &write(size_t index);
154+
void push_back(std::string_view line);
155+
void set(size_t index, std::string_view line);
163156

164157
void insert(
165158
size_t index,
166159
ekg::io::chunk_t &to_insert_chunk
167160
);
168-
161+
169162
void insert(
170163
size_t index,
171-
const std::string &line
164+
std::string_view line
172165
);
173166

174167
void erase(
175168
size_t begin,
176169
size_t end
177170
);
178171

179-
void push_back(const std::string &line);
180-
std::string &emplace_back();
181-
182-
std::vector<ekg::io::chunk_t> &data();
172+
std::vector<ekg::io::chunk_t> &chunks_data();
173+
size_t length_of_chunks();
183174

184-
size_t size();
185-
size_t lines();
186-
size_t chunks();
175+
std::string at(size_t index);
176+
size_t length_of_lines();
177+
size_t length_of_chars();
187178

188-
void unset_audited();
189179
bool audited();
190180
};
191181
}

include/ekg/ui/textbox/textbox.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,12 @@ namespace ekg {
8080
}
8181
};
8282

83-
struct untracked_line_ending_t {
84-
public:
85-
ekg::vec2_t<size_t> indices {};
86-
std::string text {};
87-
};
88-
8983
struct widget_t {
9084
public:
9185
ekg::rect_t<float> rect_text_size {};
9286
ekg::scrollbar_t scrollbar {};
9387
std::vector<ekg::textbox_t::cursor_t> cursors {};
9488
std::vector<ekg::textbox_t::select_draw_layer_t> layers_select {};
95-
std::vector<ekg::textbox_t::untracked_line_ending_t> line_ending_untracked {};
9689
size_t last_layers_select_size {};
9790
};
9891

src/handler/input/handler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ void ekg::handler::input::update() {
521521
#endif
522522

523523
ekg::reset_if_reach(this->input.ui_timing, 1000);
524-
ekg::timing_t::second = this->input.ui_timing.elapsed_ticks;
524+
ekg::timing_t::second = this->input.ui_timing.current_ticks;
525525
}
526526

527527
void ekg::handler::input::insert_input_bind(

0 commit comments

Comments
 (0)