alloc big buffers on heap
This commit is contained in:
20
src/edit.c
20
src/edit.c
@@ -39,20 +39,20 @@ void edit_delete(TimEditState* e) {
|
||||
static i32 edit_event(TimEditState* e, TimRect r) {
|
||||
if (tim_is_mouse_click_over(r)) {
|
||||
// take focus
|
||||
tim.focus = e;
|
||||
tim->focus = e;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (tim.focus != e || tim.event.type != TimEvent_Key) {
|
||||
if (tim->focus != e || tim->event.type != TimEvent_Key) {
|
||||
// not focused or no key press
|
||||
return 0;
|
||||
}
|
||||
tim.event.type = TimEvent_Void; // consume event
|
||||
tim->event.type = TimEvent_Void; // consume event
|
||||
|
||||
switch (tim.event.key) {
|
||||
switch (tim->event.key) {
|
||||
case TimKey_Escape:
|
||||
case TimKey_Enter:
|
||||
tim.focus = 0; // release focus
|
||||
tim->focus = 0; // release focus
|
||||
break;
|
||||
case TimKey_Delete:
|
||||
edit_delete(e);
|
||||
@@ -76,21 +76,21 @@ static i32 edit_event(TimEditState* e, TimRect r) {
|
||||
e->cursor = e->length;
|
||||
break;
|
||||
default:
|
||||
if (tim.event.key >= ' ') {
|
||||
edit_insert(e, tim.event.s);
|
||||
if (tim->event.key >= ' ') {
|
||||
edit_insert(e, tim->event.s);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return tim.event.key;
|
||||
return tim->event.key;
|
||||
}
|
||||
|
||||
i32 edit(TimEditState* e, i32 x, i32 y, i32 w, u64 color) {
|
||||
TimRect r = tim_scope_rect_to_absolute(x, y, w, 3);
|
||||
|
||||
if (tim.event.type == TimEvent_Draw) {
|
||||
if (tim->event.type == TimEvent_Draw) {
|
||||
tim_draw_box(r.x, r.y, r.w, r.h, color >> 16, color >> 8);
|
||||
if (tim.focus == e) {
|
||||
if (tim->focus == e) {
|
||||
char* s = e->s + tim_utf8_pos(e->s, e->cursor - r.w + 4);
|
||||
i32 cur = MIN(r.w - 4, e->cursor);
|
||||
tim_draw_str(s, r.x + 2, r.y + 1, r.w - 3, color, color >> 8);
|
||||
|
||||
Reference in New Issue
Block a user