// File: /workspace/github_c_makefile_star2_O2/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_ta.c
// Function: lv_ta_signal
static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
{
    lv_res_t res;

    /* Include the ancient signal function */
    res = ancestor_signal(ta, sign, param);
    if(res != LV_RES_OK) return res;
    if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME);

    lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
    if(sign == LV_SIGNAL_CLEANUP) {
        if(ext->pwd_tmp != NULL) lv_mem_free(ext->pwd_tmp);

        /* (The created label will be deleted automatically) */
    } else if(sign == LV_SIGNAL_STYLE_CHG) {
        if(ext->label) {
            lv_obj_t * scrl               = lv_page_get_scrl(ta);
            const lv_style_t * style_ta   = lv_obj_get_style(ta);
            const lv_style_t * style_scrl = lv_obj_get_style(scrl);
            if(ext->one_line) {
                /*In one line mode refresh the Text Area height because 'vpad' can modify it*/
                const lv_style_t * style_label = lv_obj_get_style(ext->label);
                lv_coord_t font_h              = lv_font_get_line_height(style_label->text.font);
                lv_obj_set_height(ext->label, font_h);
                lv_obj_set_height(ta, font_h + style_ta->body.padding.top + style_ta->body.padding.bottom +
                                          style_scrl->body.padding.top + style_scrl->body.padding.bottom);
            } else {
                /*In not one line mode refresh the Label width because 'hpad' can modify it*/
                lv_obj_set_width(ext->label, lv_page_get_fit_width(ta));
                lv_obj_set_pos(ext->label, style_scrl->body.padding.left,
                               style_scrl->body.padding.right); /*Be sure the Label is in the correct position*/

                if(ext->placeholder) {
                    lv_obj_set_width(ext->placeholder, lv_page_get_fit_width(ta));
                    lv_obj_set_pos(ext->placeholder, style_scrl->body.padding.left,
                                   style_scrl->body.padding.top); /*Be sure the placeholder is in the correct position*/
                }
            }
            lv_label_set_text(ext->label, NULL);
        }
    } else if(sign == LV_SIGNAL_CORD_CHG) {
        /*Set the label width according to the text area width*/
        if(ext->label) {
            if(lv_obj_get_width(ta) != lv_area_get_width(param) || lv_obj_get_height(ta) != lv_area_get_height(param)) {
                lv_obj_t * scrl               = lv_page_get_scrl(ta);
                const lv_style_t * style_scrl = lv_obj_get_style(scrl);
                lv_obj_set_width(ext->label, lv_page_get_fit_width(ta));
                lv_obj_set_pos(ext->label, style_scrl->body.padding.left, style_scrl->body.padding.top);
                lv_label_set_text(ext->label, NULL); /*Refresh the label*/

                refr_cursor_area(ta);
            }
        }
        /*Set the placeholder width according to the text area width*/
        if(ext->placeholder) {
            if(lv_obj_get_width(ta) != lv_area_get_width(param) || lv_obj_get_height(ta) != lv_area_get_height(param)) {
                lv_obj_t * scrl               = lv_page_get_scrl(ta);
                const lv_style_t * style_scrl = lv_obj_get_style(scrl);
                lv_obj_set_width(ext->placeholder, lv_page_get_fit_width(ta));
                lv_obj_set_pos(ext->placeholder, style_scrl->body.padding.left, style_scrl->body.padding.top);
                lv_label_set_text(ext->placeholder, NULL); /*Refresh the label*/

                refr_cursor_area(ta);
            }
        }
    } else if(sign == LV_SIGNAL_CONTROL) {
        uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/
        if(c == LV_KEY_RIGHT)
            lv_ta_cursor_right(ta);
        else if(c == LV_KEY_LEFT)
            lv_ta_cursor_left(ta);
        else if(c == LV_KEY_UP)
            lv_ta_cursor_up(ta);
        else if(c == LV_KEY_DOWN)
            lv_ta_cursor_down(ta);
        else if(c == LV_KEY_BACKSPACE)
            lv_ta_del_char(ta);
        else if(c == LV_KEY_DEL)
            lv_ta_del_char_forward(ta);
        else if(c == LV_KEY_HOME)
            lv_ta_set_cursor_pos(ta, 0);
        else if(c == LV_KEY_END)
            lv_ta_set_cursor_pos(ta, LV_TA_CURSOR_LAST);
        else {
            lv_ta_add_char(ta, c);
        }
    } else if(sign == LV_SIGNAL_GET_EDITABLE) {
        bool * editable = (bool *)param;
        *editable       = true;
    } else if(sign == LV_SIGNAL_DEFOCUS) {
        lv_cursor_type_t cur_type;
        cur_type = lv_ta_get_cursor_type(ta);
        lv_ta_set_cursor_type(ta, cur_type | LV_CURSOR_HIDDEN);
    } else if(sign == LV_SIGNAL_FOCUS) {
#if LV_USE_GROUP
        lv_cursor_type_t cur_type;
        cur_type                   = lv_ta_get_cursor_type(ta);
        lv_group_t * g             = lv_obj_get_group(ta);
        bool editing               = lv_group_get_editing(g);
        lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());

        /*Encoders need special handling*/
        if(indev_type == LV_INDEV_TYPE_ENCODER) {
            if(editing)
                lv_ta_set_cursor_type(ta, cur_type & (~LV_CURSOR_HIDDEN));
            else
                lv_ta_set_cursor_type(ta, cur_type | LV_CURSOR_HIDDEN);
        } else {
            lv_ta_set_cursor_type(ta, cur_type & (~LV_CURSOR_HIDDEN));
        }
#endif
    } else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_PRESSING || sign == LV_SIGNAL_PRESS_LOST ||
              sign == LV_SIGNAL_RELEASED) {
        update_cursor_position_on_click(ta, sign, (lv_indev_t *)param);
    }
    return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r12
movl %esi, %ebp
movq %rdi, %r14
callq *0x41ce1(%rip)          # 0x5e3e8
movl %eax, %ebx
cmpb $0x1, %al
jne 0x1ca5d
cmpb $0x7, %bpl
jne 0x1c734
leaq 0x1f1f0(%rip), %rsi     # 0x3b90e
movq %r12, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x684b
movq %r14, %rdi
callq 0x6747
movb $0x1, %bl
cmpb $0x13, %bpl
ja 0x1ca5d
movq %rax, %r15
movzbl %bpl, %esi
leaq 0x1f106(%rip), %rax     # 0x3b85c
movslq (%rax,%rsi,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq %r14, %rdi
movq %r12, %rdx
callq 0x1ead1
jmp 0x1ca5d
movq %r14, %rdi
callq 0x1e6f8
orb $0x8, %al
movzbl %al, %esi
jmp 0x1ca55
movb $0x1, (%r12)
jmp 0x1ca5d
movq 0x60(%r15), %rdi
testq %rdi, %rdi
je 0x1ca5d
callq 0x27a7a
jmp 0x1ca5d
cmpq $0x0, 0x50(%r15)
je 0x1ca5d
movq %r14, %rdi
callq 0x245d9
movq %rax, %r12
movq %r14, %rdi
callq 0x6316
movq %rax, %r13
movq %r12, %rdi
callq 0x6316
movq %rax, %r12
testb $0x2, 0x98(%r15)
movq 0x50(%r15), %rbp
jne 0x1ca01
movq %r14, %rdi
callq 0x2476e
movswl %ax, %esi
movq %rbp, %rdi
callq 0x53a8
movq 0x50(%r15), %rdi
movswl 0x1a(%r12), %esi
movswl 0x1c(%r12), %edx
callq 0x47df
movq 0x58(%r15), %r13
testq %r13, %r13
je 0x1ca40
movq %r14, %rdi
callq 0x2476e
movswl %ax, %esi
movq %r13, %rdi
callq 0x53a8
movq 0x58(%r15), %rdi
movswl 0x1a(%r12), %esi
movswl 0x16(%r12), %edx
callq 0x47df
jmp 0x1ca40
cmpq $0x0, 0x50(%r15)
je 0x1c8d2
movq %r14, %rdi
callq 0x5308
movzwl 0x4(%r12), %ecx
subw (%r12), %cx
incl %ecx
cmpw %cx, %ax
jne 0x1c882
movq %r14, %rdi
callq 0x5332
movzwl 0x6(%r12), %ecx
subw 0x2(%r12), %cx
incl %ecx
cmpw %cx, %ax
je 0x1c8d2
movq %r14, %rdi
callq 0x245d9
movq %rax, %rdi
callq 0x6316
movq %rax, %r13
movq 0x50(%r15), %rbp
movq %r14, %rdi
callq 0x2476e
movswl %ax, %esi
movq %rbp, %rdi
callq 0x53a8
movq 0x50(%r15), %rdi
movswl 0x1a(%r13), %esi
movswl 0x16(%r13), %edx
callq 0x47df
movq 0x50(%r15), %rdi
xorl %esi, %esi
callq 0x18a9a
movq %r14, %rdi
callq 0x1df9e
cmpq $0x0, 0x58(%r15)
je 0x1ca5d
movq %r14, %rdi
callq 0x5308
movzwl 0x4(%r12), %ecx
subw (%r12), %cx
incl %ecx
cmpw %cx, %ax
jne 0x1c916
movq %r14, %rdi
callq 0x5332
movzwl 0x6(%r12), %ecx
subw 0x2(%r12), %cx
incl %ecx
cmpw %cx, %ax
je 0x1ca5d
movq %r14, %rdi
callq 0x245d9
movq %rax, %rdi
callq 0x6316
movq %rax, %r12
movq 0x58(%r15), %r13
movq %r14, %rdi
callq 0x2476e
movswl %ax, %esi
movq %r13, %rdi
callq 0x53a8
movq 0x58(%r15), %rdi
movswl 0x1a(%r12), %esi
movswl 0x16(%r12), %edx
callq 0x47df
movq 0x58(%r15), %rdi
xorl %esi, %esi
callq 0x18a9a
movq %r14, %rdi
callq 0x1df9e
jmp 0x1ca5d
movq %r14, %rdi
callq 0x1e6f8
movl %eax, %ebp
movq %r14, %rdi
callq 0x4b8e
movq %rax, %rdi
callq 0x2aaa
movl %eax, %r15d
callq 0x35b3
movq %rax, %rdi
callq 0x35bb
cmpb $0x4, %al
jne 0x1c9a4
testb %r15b, %r15b
je 0x1ca4d
andb $0x7, %bpl
jmp 0x1ca51
movl (%r12), %esi
leal -0x11(%rsi), %eax
cmpl $0x3, %eax
jbe 0x1c9e7
movq %r14, %rdi
cmpl $0x2, %esi
je 0x1ca6e
cmpl $0x3, %esi
je 0x1ca97
cmpl $0x8, %esi
je 0x1ca7c
cmpl $0x7f, %esi
jne 0x1caa3
callq 0x1dba7
jmp 0x1ca5d
leaq 0x1eebe(%rip), %rcx     # 0x3b8ac
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r14, %rdi
callq 0x1e996
jmp 0x1ca5d
movq %rbp, %rdi
callq 0x6316
movq 0x28(%rax), %rax
movzbl 0x10(%rax), %ebp
movq 0x50(%r15), %rdi
movl %ebp, %esi
callq 0x53e6
movzwl 0x16(%r13), %eax
addw %bp, %ax
addw 0x18(%r13), %ax
addw 0x16(%r12), %ax
addw 0x18(%r12), %ax
movswl %ax, %esi
movq %r14, %rdi
callq 0x53e6
movq 0x50(%r15), %rdi
xorl %esi, %esi
callq 0x18a9a
jmp 0x1ca5d
orb $0x8, %bpl
movzbl %bpl, %esi
movq %r14, %rdi
callq 0x1e2f4
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %esi, %esi
jmp 0x1ca9c
movq %r14, %rdi
callq 0x1e85c
jmp 0x1ca5d
callq 0x1d9f5
jmp 0x1ca5d
movq %r14, %rdi
callq 0x1e890
jmp 0x1ca5d
movq %r14, %rdi
callq 0x1e8cb
jmp 0x1ca5d
movl $0x7fff, %esi           # imm = 0x7FFF
callq 0x1d679
jmp 0x1ca5d
callq 0x1d175
jmp 0x1ca5d