// File: /workspace/github_c_makefile_star2_O2/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_ta.c
// Function: lv_ta_del_char
void lv_ta_del_char(lv_obj_t * ta)
{
    LV_ASSERT_OBJ(ta, LV_OBJX_NAME);

    lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
    uint16_t cur_pos  = ext->cursor.pos;

    if(cur_pos == 0) return;

    ta_insert_replace = NULL;
    char del_buf[2]   = {LV_KEY_DEL, '\0'};
    lv_event_send(ta, LV_EVENT_INSERT, del_buf);
    if(ta_insert_replace) {
        if(ta_insert_replace[0] == '\0') return; /*Drop this text*/

        /*Add the replaced text directly it's different from the original*/
        if(strcmp(ta_insert_replace, del_buf)) {
            lv_ta_add_text(ta, ta_insert_replace);
            return;
        }
    }

    char * label_txt = lv_label_get_text(ext->label);
    /*Delete a character*/
    lv_txt_cut(label_txt, ext->cursor.pos - 1, 1);
    /*Refresh the label*/
    lv_label_set_text(ext->label, label_txt);
    lv_ta_clear_selection(ta);

    /*Don't let 'width == 0' because cursor will not be visible*/
    if(lv_obj_get_width(ext->label) == 0) {
        const lv_style_t * style = lv_obj_get_style(ext->label);
        lv_obj_set_width(ext->label, style->line.width);
    }

    if(ext->pwd_mode != 0) {
        uint32_t byte_pos = lv_txt_encoded_get_byte_id(ext->pwd_tmp, ext->cursor.pos - 1);
        lv_txt_cut(ext->pwd_tmp, ext->cursor.pos - 1, lv_txt_encoded_size(&label_txt[byte_pos]));

        ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + 1);
        LV_ASSERT_MEM(ext->pwd_tmp);
        if(ext->pwd_tmp == NULL) return;
    }

    /*Move the cursor to the place of the deleted character*/
    lv_ta_set_cursor_pos(ta, ext->cursor.pos - 1);

    placeholder_update(ta);

    lv_event_send(ta, LV_EVENT_VALUE_CHANGED, NULL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
callq 0x7994
testb %al, %al
je 0x1da7a
movq %rbx, %rdi
callq 0x6747
cmpw $0x0, 0x82(%rax)
je 0x1db8c
movq %rax, %r14
andq $0x0, 0x409da(%rip)     # 0x5e408
leaq 0xe(%rsp), %rdx
movw $0x7f, (%rdx)
pushq $0xf
popq %rsi
movq %rbx, %rdi
callq 0x4caf
movq 0x409be(%rip), %r15     # 0x5e408
testq %r15, %r15
je 0x1da8b
cmpb $0x0, (%r15)
je 0x1db8c
leaq 0xe(%rsp), %rsi
movq %r15, %rdi
callq 0x20e0
testl %eax, %eax
je 0x1da8b
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1d3f2
jmp 0x1db8c
leaq 0x1d6c3(%rip), %rdi     # 0x3b144
movq %rbx, %rsi
callq 0x7b01
jmp 0x1da89
movq 0x50(%r14), %rdi
callq 0x18db9
movq %rax, %r15
movzwl 0x82(%r14), %esi
decl %esi
pushq $0x1
popq %rdx
movq %rax, %rdi
callq 0x28d35
movq 0x50(%r14), %rdi
movq %r15, %rsi
callq 0x18a9a
movq %rbx, %rdi
callq 0x1d650
movq 0x50(%r14), %rdi
callq 0x5308
testw %ax, %ax
jne 0x1dae4
movq 0x50(%r14), %rdi
callq 0x6316
movq 0x50(%r14), %rdi
movswl 0x3e(%rax), %esi
callq 0x53a8
testb $0x1, 0x98(%r14)
je 0x1db62
leaq 0x33b4b(%rip), %rax     # 0x51640
movq 0x60(%r14), %rdi
movzwl 0x82(%r14), %esi
decl %esi
callq *(%rax)
movq 0x60(%r14), %r12
movzwl 0x82(%r14), %ebp
decl %ebp
leaq 0x33afe(%rip), %rcx     # 0x51618
movl %eax, %eax
addq %rax, %r15
movq %r15, %rdi
callq *(%rcx)
movzbl %al, %edx
movq %r12, %rdi
movl %ebp, %esi
callq 0x28d35
movq 0x60(%r14), %r15
movq %r15, %rdi
callq 0x2070
leaq 0x1(%rax), %rsi
movq %r15, %rdi
callq 0x27ad9
movq %rax, 0x60(%r14)
movq %rax, %rdi
callq 0x7994
movq 0x60(%r14), %rsi
testb %al, %al
je 0x1db99
testq %rsi, %rsi
je 0x1db8c
movzwl 0x82(%r14), %eax
decl %eax
movswl %ax, %esi
movq %rbx, %rdi
callq 0x1d679
movq %rbx, %rdi
callq 0x1d8ff
pushq $0xe
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x4caf
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1d4a0(%rip), %rdi     # 0x3b040
callq 0x7b01
jmp 0x1dba5