// File: /workspace/github_c_makefile_star2_O1/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 0x80d4
testb %al, %al
je 0x1f1f4
movq %rbx, %rdi
callq 0x6ad8
cmpw $0x0, 0x82(%rax)
je 0x1f312
movq %rax, %r14
movq $0x0, 0x41262(%rip) # 0x60408
leaq 0xe(%rsp), %rdx
movw $0x7f, (%rdx)
movq %rbx, %rdi
movl $0xf, %esi
callq 0x4fea
movq 0x41244(%rip), %r15     # 0x60408
testq %r15, %r15
je 0x1f205
cmpb $0x0, (%r15)
je 0x1f312
leaq 0xe(%rsp), %rsi
movq %r15, %rdi
callq 0x20e0
testl %eax, %eax
je 0x1f205
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1eb68
jmp 0x1f312
leaq 0x1ff39(%rip), %rdi     # 0x3f134
movq %rbx, %rsi
callq 0x829e
jmp 0x1f203
movq 0x50(%r14), %rdi
callq 0x1a239
movq %rax, %r15
movzwl 0x82(%r14), %esi
decl %esi
movq %rax, %rdi
movl $0x1, %edx
callq 0x2ad28
movq 0x50(%r14), %rdi
movq %r15, %rsi
callq 0x19f13
movq %rbx, %rdi
callq 0x80d4
testb %al, %al
je 0x1f31f
movq 0x50(%r14), %rdi
callq 0x5651
testw %ax, %ax
jne 0x1f268
movq 0x50(%r14), %rdi
callq 0x6697
movq 0x50(%r14), %rdi
movswl 0x3e(%rax), %esi
callq 0x56f1
testb $0x1, 0x98(%r14)
je 0x1f2e6
leaq 0x343c7(%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 0x3437a(%rip), %rcx     # 0x53618
movl %eax, %eax
addq %rax, %r15
movq %r15, %rdi
callq *(%rcx)
movzbl %al, %edx
movq %r12, %rdi
movl %ebp, %esi
callq 0x2ad28
movq 0x60(%r14), %r15
movq %r15, %rdi
callq 0x2070
leaq 0x1(%rax), %rsi
movq %r15, %rdi
callq 0x299f8
movq %rax, 0x60(%r14)
movq %rax, %rdi
callq 0x80d4
movq 0x60(%r14), %rsi
testb %al, %al
je 0x1f330
testq %rsi, %rsi
je 0x1f312
movzwl 0x82(%r14), %eax
decl %eax
movswl %ax, %esi
movq %rbx, %rdi
callq 0x1edf8
movq %rbx, %rdi
callq 0x1f074
movq %rbx, %rdi
movl $0xe, %esi
xorl %edx, %edx
callq 0x4fea
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1fe0e(%rip), %rdi     # 0x3f134
movq %rbx, %rsi
callq 0x829e
jmp 0x1f32e
leaq 0x1fd09(%rip), %rdi     # 0x3f040
callq 0x829e
jmp 0x1f33c