Skip to content

Commit 195e38a

Browse files
committed
[fix] tpyiong at end
1 parent 98aa846 commit 195e38a

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/io/utf.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ bool ekg::utf8_find_byte_pos_by_utf_pos(
187187
size_t string_size {string.size()};
188188
size_t utf_pos_count {};
189189

190-
for (size_t it {}; it < string_size; it++) {
190+
size_t it {};
191+
for (; it < string_size; it++) {
191192
if (utf_pos_count == utf_pos) {
192193
byte_pos = it;
193194
return true;
@@ -203,6 +204,11 @@ bool ekg::utf8_find_byte_pos_by_utf_pos(
203204
utf_pos_count++;
204205
}
205206

207+
if (utf_pos_count == utf_pos) {
208+
byte_pos = it;
209+
return true;
210+
}
211+
206212
return false;
207213
}
208214

@@ -399,7 +405,7 @@ size_t ekg::utf8_split_endings(
399405
return new_lines_count;
400406
}
401407

402-
void ekg:: utf8_concat(
408+
void ekg::utf8_concat(
403409
std::string &string,
404410
const ekg::vec4_t<std::size_t> &stride,
405411
std::string &concated
@@ -415,6 +421,7 @@ void ekg:: utf8_concat(
415421
concated.clear();
416422
if (!a.empty() || !b.empty()) {
417423
concated = a + b;
424+
ekg_log_low_level(a << " x " << b)
418425
}
419426
}
420427

@@ -632,6 +639,7 @@ void ekg::text::erase(
632639
if (begin <= lines) {
633640
remains_lines = end - begin;
634641
begin = begin - previous_lines;
642+
635643
while (remains_lines != 0) {
636644
ekg::io::chunk_t &chunk {this->loaded_chunks.at(it)};
637645

src/ui/textbox/widget.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ void ekg::ui::handle_erase(
287287
std::string line {textbox.text.at(cursor.a.y)};
288288
std::string concated {};
289289

290+
ekg_log_low_level(cursor.a.x << " | " << cursor.b.x);
291+
290292
ekg::utf8_concat(
291293
line,
292294
{0, cursor.a.x, cursor.b.x, line.size()},
@@ -593,6 +595,8 @@ void ekg::ui::event(
593595
ekg::vec2_t<float> cursor_pos {};
594596
std::string line {};
595597

598+
ekg_log_low_level("xup << " << textbox.widget.cursors.size());
599+
596600
for (ekg::textbox_t::cursor_t &cursor : textbox.widget.cursors) {
597601
is_ab_equals = cursor.a == cursor.b;
598602

@@ -609,24 +613,32 @@ void ekg::ui::event(
609613
**/
610614
if (
611615
is_action_selected_fired
616+
&&
617+
!(is_action_erase_left_fired || is_action_erase_left_fired)
612618
) {
613619
if (cursor == cursor.delta && is_left_fired) {
614620
cursor.b = cursor.a;
615621
cursor.direction = ekg::dock::left;
622+
ekg_log_low_level("aa");
616623
} else if (cursor == cursor.delta && is_right_fired) {
617624
cursor.a = cursor.b;
618625
cursor.direction = ekg::dock::right;
626+
ekg_log_low_level("bb");
619627
} else if (cursor < cursor.delta) {
620628
cursor.a = cursor.b;
621629
cursor.direction = ekg::dock::right;
630+
ekg_log_low_level("cc");
622631
} else if (cursor > cursor.delta) {
623632
cursor.b = cursor.a;
624633
cursor.direction = ekg::dock::left;
634+
ekg_log_low_level("dd");
625635
}
626636

627637
is_ab_equals = true;
628638
}
629639

640+
ekg_log_low_level("merow");
641+
630642
if (is_left_fired) {
631643
if (is_ab_equals) {
632644
if (cursor.a.x > 0) {
@@ -776,15 +788,19 @@ void ekg::ui::event(
776788
if (cursor == cursor.delta && is_left_fired) {
777789
cursor.b = cursor.a;
778790
cursor.direction = ekg::dock::left;
791+
ekg_log_low_level("a");
779792
} else if (cursor == cursor.delta && is_right_fired) {
780793
cursor.a = cursor.b;
781794
cursor.direction = ekg::dock::right;
795+
ekg_log_low_level("b");
782796
} else if (cursor < cursor.delta) {
783797
cursor.a = cursor.b;
784798
cursor.direction = ekg::dock::right;
799+
ekg_log_low_level("c");
785800
} else if (cursor > cursor.delta) {
786801
cursor.b = cursor.a;
787802
cursor.direction = ekg::dock::left;
803+
ekg_log_low_level("d");
788804
}
789805

790806
highest = cursor.highest_char_index;
@@ -805,6 +821,7 @@ void ekg::ui::event(
805821
}
806822
} else {
807823
cursor.delta = cursor.a;
824+
ekg_log_low_level(cursor.delta.x << " xu " );
808825
}
809826

810827
if (is_action_erase_fired) {

0 commit comments

Comments
 (0)