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

    lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);

    uint32_t letter_buf[2];
    letter_buf[0] = c;
    letter_buf[1] = '\0';

    ta_insert_replace = NULL;
    lv_event_send(ta, LV_EVENT_INSERT, letter_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, (char *)letter_buf)) {
            lv_ta_add_text(ta, ta_insert_replace);
            return;
        }
    }

    if(ext->one_line && (c == '\n' || c == '\r')) {
        LV_LOG_INFO("Text area: line break ignored in one-line mode");
        return;
    }

    uint32_t c_uni = lv_txt_encoded_next((const char *)&c, NULL);

    if(char_is_accepted(ta, c_uni) == false) {
        LV_LOG_INFO("Character is no accepted by the text area (too long text or not in the "
                    "accepted list)");
        return;
    }

    /*If a new line was added it shouldn't show edge flash effect*/
    bool edge_flash_en = lv_ta_get_edge_flash(ta);
    lv_ta_set_edge_flash(ta, false);

    if(ext->pwd_mode != 0) pwd_char_hider(ta); /*Make sure all the current text contains only '*'*/

    lv_label_ins_text(ext->label, ext->cursor.pos, (const char *)letter_buf); /*Insert the character*/
    lv_ta_clear_selection(ta);                                                /*Clear selection*/

    if(ext->pwd_mode != 0) {

        ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + 2); /*+2: the new char + \0 */
        LV_ASSERT_MEM(ext->pwd_tmp);
        if(ext->pwd_tmp == NULL) return;

        lv_txt_ins(ext->pwd_tmp, ext->cursor.pos, (const char *)letter_buf);

#if LV_USE_ANIMATION
        /*Auto hide characters*/
        lv_anim_t a;
        a.var            = ta;
        a.exec_cb        = (lv_anim_exec_xcb_t)pwd_char_hider_anim;
        a.time           = ext->pwd_show_time;
        a.act_time       = 0;
        a.ready_cb       = pwd_char_hider_anim_ready;
        a.start          = 0;
        a.end            = 1;
        a.repeat         = 0;
        a.repeat_pause   = 0;
        a.playback       = 0;
        a.playback_pause = 0;
        a.path_cb        = lv_anim_path_step;
        lv_anim_create(&a);

#else
        pwd_char_hider(ta);
#endif
    }

    /*Move the cursor after the new character*/
    lv_ta_set_cursor_pos(ta, lv_ta_get_cursor_pos(ta) + 1);

    /*Revert the original edge flash state*/
    lv_ta_set_edge_flash(ta, edge_flash_en);

    placeholder_update(ta);

    lv_event_send(ta, LV_EVENT_VALUE_CHANGED, NULL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movl %esi, 0xc(%rsp)
callq 0x7994
testb %al, %al
je 0x1d1f5
movq %rbx, %rdi
callq 0x6747
leaq 0x4(%rsp), %rdx
movl %ebp, (%rdx)
andl $0x0, 0x4(%rdx)
movq %rax, %r14
andq $0x0, 0x41255(%rip)     # 0x5e408
pushq $0xf
popq %rsi
movq %rbx, %rdi
callq 0x4caf
movq 0x41243(%rip), %r15     # 0x5e408
testq %r15, %r15
je 0x1d206
cmpb $0x0, (%r15)
je 0x1d3d5
leaq 0x4(%rsp), %rsi
movq %r15, %rdi
callq 0x20e0
testl %eax, %eax
je 0x1d206
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1d3f2
jmp 0x1d3d5
leaq 0x1df48(%rip), %rdi     # 0x3b144
movq %rbx, %rsi
callq 0x7b01
jmp 0x1d204
testb $0x2, 0x98(%r14)
je 0x1d222
cmpl $0xa, %ebp
je 0x1d3d5
cmpl $0xd, %ebp
je 0x1d3d5
leaq 0x34407(%rip), %r13     # 0x51630
leaq 0xc(%rsp), %rdi
xorl %esi, %esi
callq *(%r13)
movl %eax, %ebp
movq %rbx, %rdi
callq 0x6747
movq %rax, %r15
cmpq $0x0, 0x68(%rax)
movzwl 0x70(%rax), %eax
je 0x1d253
testw %ax, %ax
jne 0x1d258
jmp 0x1d284
testw %ax, %ax
je 0x1d2ab
leaq 0x343f1(%rip), %rax     # 0x51650
movq (%rax), %r12
movq %rbx, %rdi
callq 0x1e680
movq %rax, %rdi
callq *%r12
movzwl 0x70(%r15), %ecx
cmpl %ecx, %eax
jae 0x1d3d5
cmpq $0x0, 0x68(%r15)
je 0x1d2ab
leaq 0x10(%rsp), %r12
andl $0x0, (%r12)
movq 0x68(%r15), %rdi
movl 0x10(%rsp), %eax
cmpb $0x0, (%rdi,%rax)
je 0x1d3d5
movq %r12, %rsi
callq *(%r13)
cmpl %ebp, %eax
jne 0x1d28e
movq %rbx, %rdi
callq 0x24741
movl %eax, %ebp
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2467a
testb $0x1, 0x98(%r14)
je 0x1d2d1
movq %rbx, %rdi
callq 0x1ceb6
movq 0x50(%r14), %rdi
movzwl 0x82(%r14), %esi
leaq 0x4(%rsp), %rdx
callq 0x1a0c6
movq %rbx, %rdi
callq 0x1d650
testb $0x1, 0x98(%r14)
je 0x1d39f
movq 0x60(%r14), %r15
movq %r15, %rdi
callq 0x2070
leaq 0x2(%rax), %rsi
movq %r15, %rdi
callq 0x27ad9
movq %rax, 0x60(%r14)
movq %rax, %rdi
callq 0x7994
movq 0x60(%r14), %rsi
testb %al, %al
je 0x1d3e4
testq %rsi, %rsi
je 0x1d3d5
movzwl 0x82(%r14), %eax
leaq 0x4(%rsp), %rdx
movq %rsi, %rdi
movl %eax, %esi
callq 0x28cce
leaq 0x10(%rsp), %rdi
movq %rbx, (%rdi)
leaq 0x314(%rip), %rax       # 0x1d670
movq %rax, 0x8(%rdi)
movzwl 0x72(%r14), %eax
movw %ax, 0x28(%rdi)
andw $0x0, 0x2a(%rdi)
leaq 0x2fc(%rip), %rax       # 0x1d671
movq %rax, 0x18(%rdi)
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x20(%rdi)
andl $0x0, 0x2c(%rdi)
movb $0x0, 0x30(%rdi)
leaq 0xa633(%rip), %rax      # 0x279c9
movq %rax, 0x10(%rdi)
callq 0x27685
movq %rbx, %rdi
callq 0x1d8d0
incl %eax
movswl %ax, %esi
movq %rbx, %rdi
callq 0x1d679
movzbl %bpl, %esi
movq %rbx, %rdi
callq 0x2467a
movq %rbx, %rdi
callq 0x1d8ff
pushq $0xe
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x4caf
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1dc55(%rip), %rdi     # 0x3b040
callq 0x7b01
jmp 0x1d3f0