Skip to content

Commit fc197bb

Browse files
committed
[fix] multiline insert
1 parent ad26104 commit fc197bb

File tree

2 files changed

+97
-27
lines changed

2 files changed

+97
-27
lines changed

src/handler/theme/handler.cpp

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void ekg::handler::theme::init() {
3030
ekg::theme_t light_pinky_theme {
3131
.tag = "light-pinky",
3232
.author = "Rina Wilk",
33-
.description = "wasted love of my life, no love no more love no more"
33+
.description = "amo vc amo vc"
3434
};
3535

3636
light_pinky_theme.layout_offset = 2.0f;
@@ -89,7 +89,7 @@ void ekg::handler::theme::init() {
8989
ekg::theme_t black_light_pinky_theme {
9090
.tag = "black-light-pinky",
9191
.author = "Rina Wilk",
92-
.description = "loved a shitty person God save me"
92+
.description = "oiiiiiiiii eu amo vc serpa, lindo maravilhoso"
9393
};
9494

9595
black_light_pinky_theme.layout_offset = 2.0f;
@@ -143,6 +143,65 @@ void ekg::handler::theme::init() {
143143

144144
this->registry(black_light_pinky_theme.tag) = black_light_pinky_theme;
145145
//this->set_current_theme(black_light_pinky_theme.tag);
146+
147+
ekg::theme_t black_pinky {
148+
.tag = "black-pinky",
149+
.author = "serpa",
150+
.description = "colors for show colors"
151+
};
152+
153+
black_pinky.layout_offset = 2.0f;
154+
black_pinky.layout_margin_thickness = 2;
155+
black_pinky.frame_color_scheme.background = {242, 242, 242, 255};
156+
black_pinky.frame_color_scheme.highlight = {242, 242, 242, 0};
157+
black_pinky.frame_color_scheme.outline = {190, 190, 190, 0};
158+
black_pinky.frame_color_scheme.active = {242, 242, 242, 0};
159+
black_pinky.frame_color_scheme.focused_background = {242, 242, 242, 0};
160+
black_pinky.frame_color_scheme.focused_outline = {242, 242, 242, 0};
161+
black_pinky.frame_color_scheme.warning_outline = {242, 242, 0, 100};
162+
black_pinky.frame_color_scheme.actions_margin_pixel_thickness = 18;
163+
164+
black_pinky.button_color_scheme.text_foreground = {141, 141, 141, 255};
165+
black_pinky.button_color_scheme.background = {204, 204, 204, 50};
166+
black_pinky.button_color_scheme.active = {245, 169, 184, 100};
167+
black_pinky.button_color_scheme.outline = {202, 207, 222, 0};
168+
black_pinky.button_color_scheme.highlight = {245, 169, 184, 50};
169+
black_pinky.button_color_scheme.text_foreground = {141, 141, 141, 255};
170+
black_pinky.button_color_scheme.box_outline = black_pinky.button_color_scheme.outline;
171+
black_pinky.button_color_scheme.box_active = {245, 169, 184, 200};
172+
black_pinky.button_color_scheme.box_highlight = {245, 169, 184, 50};
173+
black_pinky.button_color_scheme.box_background = {202, 207, 222, 100};
174+
175+
black_pinky.label_color_scheme.background = {204, 204, 204, 0};
176+
black_pinky.label_color_scheme.outline = {202, 207, 222, 0};
177+
black_pinky.label_color_scheme.text_foreground = {141, 141, 141, 255};
178+
179+
black_pinky.scrollbar_color_scheme.background = {204, 204, 204, 30};
180+
black_pinky.scrollbar_color_scheme.outline = {204, 204, 204, 0};
181+
black_pinky.scrollbar_color_scheme.bar_background = {245, 169, 184, 100};
182+
black_pinky.scrollbar_color_scheme.bar_highlight = {245, 169, 184, 50};
183+
black_pinky.scrollbar_color_scheme.bar_active = {245, 169, 184, 100};
184+
185+
black_pinky.slider_color_scheme.outline = {204, 204, 204, 0};
186+
black_pinky.slider_color_scheme.background = {204, 204, 204, 30};
187+
black_pinky.slider_color_scheme.bar_background = {204, 204, 204, 50};
188+
black_pinky.slider_color_scheme.bar_highlight = {245, 169, 184, 50};
189+
black_pinky.slider_color_scheme.bar_active = {245, 169, 184, 100};
190+
black_pinky.slider_color_scheme.text_foreground = {141, 141, 141, 255};
191+
192+
black_pinky.popup_color_scheme = black_pinky.frame_color_scheme;
193+
black_pinky.popup_color_scheme.outline = {50, 50, 50, 100};
194+
black_pinky.popup_color_scheme.popup_mode = true;
195+
196+
black_pinky.textbox_color_scheme.background = {20, 34, 21, 255};
197+
black_pinky.textbox_color_scheme.outline = {190, 190, 190, 100};
198+
black_pinky.textbox_color_scheme.text_foreground = {242, 242, 242, 255};
199+
black_pinky.textbox_color_scheme.text_cursor_foreground = {141, 141, 141, 255};
200+
black_pinky.textbox_color_scheme.text_select_foreground = {245, 169, 184, 50};
201+
black_pinky.textbox_color_scheme.text_select_outline = {245, 169, 184, 100};
202+
203+
this->registry(black_pinky.tag) = black_pinky;
204+
this->set_current_theme(black_pinky.tag);
146205
}
147206

148207
void ekg::handler::theme::quit() {

src/ui/textbox/widget.cpp

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,31 @@ void ekg::ui::refresh_cursors_pos(
4545
for (ekg::textbox_t::cursor_t &cursor : textbox.widget.cursors) {
4646
if (cursor.is_ignored || cursor.a.y < origin.a.y) continue;
4747

48+
if (cursor.a.y > origin.b.y) {
49+
cursor.a.y += displacement_a.y;
50+
cursor.b.y += displacement_b.y;
51+
}
52+
4853
if (cursor.a.y == origin.b.y && cursor.a.x > origin.b.x) {
4954
cursor.a.x += displacement_a.x;
55+
cursor.a.y += displacement_a.y;
5056
}
5157

5258
if (cursor.b.y == origin.b.y && cursor.b.x > origin.b.x) {
5359
cursor.b.x += displacement_b.x;
54-
}
55-
56-
if (cursor.a.y >= origin.b.y) {
57-
cursor.a.y += displacement_a.y;
58-
cursor.b.y += displacement_b.y;
60+
cursor.b.y += displacement_b.y;
5961
}
6062
}
6163
break;
6264
case ekg::ui::textbox_operation::insert_inline:
6365
for (ekg::textbox_t::cursor_t &cursor : textbox.widget.cursors) {
6466
if (cursor.is_ignored || cursor.a.y < origin.a.y) continue;
6567

66-
if (cursor.a.y == origin.b.y && cursor.a.x > origin.b.x) {
68+
if (cursor.a.y == origin.a.y && cursor.a.x > origin.a.x) {
6769
cursor.a.x += displacement_a.x;
6870
}
6971

70-
if (cursor.b.y == origin.b.y && cursor.b.x > origin.b.x) {
72+
if (cursor.b.y == origin.a.y && cursor.b.x > origin.a.x) {
7173
cursor.b.x += displacement_b.x;
7274
}
7375
}
@@ -76,31 +78,42 @@ void ekg::ui::refresh_cursors_pos(
7678
for (ekg::textbox_t::cursor_t &cursor : textbox.widget.cursors) {
7779
if (cursor.is_ignored || cursor.a.y < origin.a.y) continue;
7880

79-
if (cursor.a.y == origin.b.y && cursor.a.x > origin.b.x) {
80-
cursor.a.x += displacement_a.x;
81+
if (cursor.a.y > origin.a.y) {
8182
cursor.a.y += displacement_a.y;
83+
cursor.b.y += displacement_b.y;
8284
}
8385

84-
if (cursor.b.y == origin.b.y && cursor.b.x > origin.b.x) {
85-
cursor.b.x += displacement_b.x;
86-
cursor.b.y += displacement_b.y;
86+
if (cursor.a.y == origin.a.y && cursor.a.x > origin.a.x) {
87+
cursor.a.x = (origin.b.x > origin.a.x)
88+
? cursor.a.x + (origin.b.x - origin.a.x)
89+
: cursor.a.x - (origin.a.x - origin.b.x);
90+
cursor.a.y += displacement_a.y;
8791
}
8892

89-
if (cursor.a.y >= origin.b.y) {
90-
cursor.a.y += displacement_a.y;
91-
cursor.b.y += displacement_b.y;
93+
if (cursor.b.y == origin.a.y && cursor.b.x > origin.a.x) {
94+
cursor.b.x = (origin.b.x > origin.a.x)
95+
? cursor.b.x + (origin.b.x - origin.a.x)
96+
: cursor.b.x - (origin.a.x - origin.b.x);
97+
cursor.b.y += displacement_b.y;
9298
}
9399
}
94100
break;
95101
case ekg::ui::textbox_operation::erase_inline:
96102
for (ekg::textbox_t::cursor_t &cursor : textbox.widget.cursors) {
97103
if (cursor.is_ignored || cursor.a.y < origin.a.y) continue;
104+
105+
if (cursor.a.y > origin.b.y) {
106+
cursor.a.y -= displacement_a.y;
107+
cursor.b.y -= displacement_b.y;
108+
}
109+
98110
if (
99111
cursor.a.y == origin.a.y
100112
&&
101113
cursor.a.x > origin.a.x
102114
) {
103115
cursor.a.x = cursor.a.x - displacement_a.x;
116+
cursor.a.y -= displacement_a.y;
104117
}
105118

106119
if (
@@ -109,10 +122,6 @@ void ekg::ui::refresh_cursors_pos(
109122
cursor.b.x > origin.b.x
110123
) {
111124
cursor.b.x = cursor.b.x - displacement_b.x;
112-
}
113-
114-
if (cursor.a.y >= origin.b.y) {
115-
cursor.a.y -= displacement_a.y;
116125
cursor.b.y -= displacement_b.y;
117126
}
118127
}
@@ -121,6 +130,11 @@ void ekg::ui::refresh_cursors_pos(
121130
for (ekg::textbox_t::cursor_t &cursor : textbox.widget.cursors) {
122131
if (cursor.is_ignored || cursor.a.y < origin.a.y) continue;
123132

133+
if (cursor.a.y > origin.b.y) {
134+
cursor.a.y -= displacement_a.y;
135+
cursor.b.y -= displacement_b.y;
136+
}
137+
124138
if (
125139
cursor.a.y == origin.b.y
126140
&&
@@ -130,6 +144,7 @@ void ekg::ui::refresh_cursors_pos(
130144
cursor.a.x - (origin.b.x - origin.a.x)
131145
:
132146
cursor.a.x + (origin.a.x - origin.b.x);
147+
cursor.a.y -= displacement_a.y;
133148
}
134149

135150
if (
@@ -141,10 +156,6 @@ void ekg::ui::refresh_cursors_pos(
141156
cursor.b.x- (origin.b.x - origin.a.x)
142157
:
143158
cursor.b.x + (origin.a.x - origin.b.x);
144-
}
145-
146-
if (cursor.a.y >= origin.b.y) {
147-
cursor.a.y -= displacement_a.y;
148159
cursor.b.y -= displacement_b.y;
149160
}
150161
}
@@ -565,8 +576,6 @@ void ekg::ui::handle_insert(
565576
);
566577

567578
ekg::textbox_t::cursor_t origin {cursor};
568-
origin.b = origin.a;
569-
570579
ekg::vec2_t<size_t> displacement_a {};
571580
ekg::vec2_t<size_t> displacement_b {};
572581

@@ -592,6 +601,8 @@ void ekg::ui::handle_insert(
592601
cursor.a.x = displacement_a.x;
593602
}
594603

604+
origin.b = cursor.a;
605+
595606
cursor.is_ignored = true;
596607
ekg::ui::refresh_cursors_pos(
597608
textbox,

0 commit comments

Comments
 (0)