// File: /workspace/github_c_makefile_star2_O3/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 0x80e4
testb %al, %al
je 0x1f9d2
movq %rbx, %rdi
callq 0x6af7
cmpw $0x0, 0x82(%rax)
je 0x1faf0
movq %rax, %r14
movq $0x0, 0x40a84(%rip) # 0x60408
leaq 0xe(%rsp), %rdx
movw $0x7f, (%rdx)
movq %rbx, %rdi
movl $0xf, %esi
callq 0x5018
movq 0x40a66(%rip), %r15     # 0x60408
testq %r15, %r15
je 0x1f9e3
cmpb $0x0, (%r15)
je 0x1faf0
leaq 0xe(%rsp), %rsi
movq %r15, %rdi
callq 0x20e0
testl %eax, %eax
je 0x1f9e3
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1f336
jmp 0x1faf0
leaq 0x1f80b(%rip), %rdi     # 0x3f1e4
movq %rbx, %rsi
callq 0x8294
jmp 0x1f9e1
movq 0x50(%r14), %rdi
callq 0x1aa00
movq %rax, %r15
movzwl 0x82(%r14), %esi
decl %esi
movq %rax, %rdi
movl $0x1, %edx
callq 0x2b473
movq 0x50(%r14), %rdi
movq %r15, %rsi
callq 0x1a6da
movq %rbx, %rdi
callq 0x80e4
testb %al, %al
je 0x1fafd
movq 0x50(%r14), %rdi
callq 0x566d
testw %ax, %ax
jne 0x1fa46
movq 0x50(%r14), %rdi
callq 0x66b6
movq 0x50(%r14), %rdi
movswl 0x3e(%rax), %esi
callq 0x570d
testb $0x1, 0x98(%r14)
je 0x1fac4
leaq 0x33be9(%rip), %rax     # 0x53640
movq 0x60(%r14), %rdi
movzwl 0x82(%r14), %esi
decl %esi
callq *(%rax)
movq 0x60(%r14), %r12
movzwl 0x82(%r14), %ebp
decl %ebp
leaq 0x33b9c(%rip), %rcx     # 0x53618
movl %eax, %eax
addq %rax, %r15
movq %r15, %rdi
callq *(%rcx)
movzbl %al, %edx
movq %r12, %rdi
movl %ebp, %esi
callq 0x2b473
movq 0x60(%r14), %r15
movq %r15, %rdi
callq 0x2070
leaq 0x1(%rax), %rsi
movq %r15, %rdi
callq 0x2a06f
movq %rax, 0x60(%r14)
movq %rax, %rdi
callq 0x80e4
movq 0x60(%r14), %rsi
testb %al, %al
je 0x1fb0e
testq %rsi, %rsi
je 0x1faf0
movzwl 0x82(%r14), %eax
decl %eax
movswl %ax, %esi
movq %rbx, %rdi
callq 0x1f5c6
movq %rbx, %rdi
callq 0x1f852
movq %rbx, %rdi
movl $0xe, %esi
xorl %edx, %edx
callq 0x5018
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1f6e0(%rip), %rdi     # 0x3f1e4
movq %rbx, %rsi
callq 0x8294
jmp 0x1fb0c
leaq 0x1f5bb(%rip), %rdi     # 0x3f0d0
callq 0x8294
jmp 0x1fb1a