// File: /workspace/github_c_makefile_star2_O3/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 *0x41dff(%rip)          # 0x603e8
movl %eax, %ebx
cmpb $0x1, %al
jne 0x1e942
cmpb $0x7, %bpl
jne 0x1e616
leaq 0x2140e(%rip), %rsi     # 0x3fa0e
movq %r12, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6c02
movq %r14, %rdi
callq 0x6af7
movb $0x1, %bl
cmpb $0x13, %bpl
ja 0x1e942
movq %rax, %r15
movzbl %bpl, %esi
leaq 0x21324(%rip), %rax     # 0x3f95c
movslq (%rax,%rsi,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq %r14, %rdi
movq %r12, %rdx
callq 0x20aef
jmp 0x1e942
movq %r14, %rdi
callq 0x20713
orb $0x8, %al
movzbl %al, %esi
jmp 0x1e93a
movb $0x1, (%r12)
jmp 0x1e942
movq 0x60(%r15), %rdi
testq %rdi, %rdi
je 0x1e942
callq 0x2a006
jmp 0x1e942
cmpq $0x0, 0x50(%r15)
je 0x1e942
movq %r14, %rdi
callq 0x2695e
movq %rax, %r12
movq %r14, %rdi
callq 0x66b6
movq %rax, %r13
movq %r12, %rdi
callq 0x66b6
movq %rax, %r12
testb $0x2, 0x98(%r15)
movq 0x50(%r15), %rbp
jne 0x1e8e6
movq %r14, %rdi
callq 0x26af3
movswl %ax, %esi
movq %rbp, %rdi
callq 0x570d
movq 0x50(%r15), %rdi
movswl 0x1a(%r12), %esi
movswl 0x1c(%r12), %edx
callq 0x4ad8
movq 0x58(%r15), %r13
testq %r13, %r13
je 0x1e925
movq %r14, %rdi
callq 0x26af3
movswl %ax, %esi
movq %r13, %rdi
callq 0x570d
movq 0x58(%r15), %rdi
movswl 0x1a(%r12), %esi
movswl 0x16(%r12), %edx
callq 0x4ad8
jmp 0x1e925
cmpq $0x0, 0x50(%r15)
je 0x1e7b4
movq %r14, %rdi
callq 0x566d
movzwl 0x4(%r12), %ecx
subw (%r12), %cx
incl %ecx
cmpw %cx, %ax
jne 0x1e764
movq %r14, %rdi
callq 0x5697
movzwl 0x6(%r12), %ecx
subw 0x2(%r12), %cx
incl %ecx
cmpw %cx, %ax
je 0x1e7b4
movq %r14, %rdi
callq 0x2695e
movq %rax, %rdi
callq 0x66b6
movq %rax, %r13
movq 0x50(%r15), %rbp
movq %r14, %rdi
callq 0x26af3
movswl %ax, %esi
movq %rbp, %rdi
callq 0x570d
movq 0x50(%r15), %rdi
movswl 0x1a(%r13), %esi
movswl 0x16(%r13), %edx
callq 0x4ad8
movq 0x50(%r15), %rdi
xorl %esi, %esi
callq 0x1a6da
movq %r14, %rdi
callq 0x1ff6e
cmpq $0x0, 0x58(%r15)
je 0x1e942
movq %r14, %rdi
callq 0x566d
movzwl 0x4(%r12), %ecx
subw (%r12), %cx
incl %ecx
cmpw %cx, %ax
jne 0x1e7f8
movq %r14, %rdi
callq 0x5697
movzwl 0x6(%r12), %ecx
subw 0x2(%r12), %cx
incl %ecx
cmpw %cx, %ax
je 0x1e942
movq %r14, %rdi
callq 0x2695e
movq %rax, %rdi
callq 0x66b6
movq %rax, %r12
movq 0x58(%r15), %r13
movq %r14, %rdi
callq 0x26af3
movswl %ax, %esi
movq %r13, %rdi
callq 0x570d
movq 0x58(%r15), %rdi
movswl 0x1a(%r12), %esi
movswl 0x16(%r12), %edx
callq 0x4ad8
movq 0x58(%r15), %rdi
xorl %esi, %esi
callq 0x1a6da
movq %r14, %rdi
callq 0x1ff6e
jmp 0x1e942
movq %r14, %rdi
callq 0x20713
movl %eax, %ebp
movq %r14, %rdi
callq 0x4ed1
movq %rax, %rdi
callq 0x2b0b
movl %eax, %r15d
callq 0x378a
movq %rax, %rdi
callq 0x3792
cmpb $0x4, %al
jne 0x1e886
testb %r15b, %r15b
je 0x1e932
andb $0x7, %bpl
jmp 0x1e936
movl (%r12), %esi
cmpl $0x10, %esi
jle 0x1e8c1
leal -0x11(%rsi), %eax
cmpl $0x3, %eax
ja 0x1e953
leaq 0x21101(%rip), %rcx     # 0x3f9ac
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r14, %rdi
callq 0x209b1
jmp 0x1e942
cmpl $0x2, %esi
je 0x1e962
cmpl $0x3, %esi
je 0x1e97d
cmpl $0x8, %esi
jne 0x1e969
movq %r14, %rdi
callq 0x1f948
jmp 0x1e942
movq %rbp, %rdi
callq 0x66b6
movq 0x28(%rax), %rax
movzbl 0x10(%rax), %ebp
movq 0x50(%r15), %rdi
movl %ebp, %esi
callq 0x574b
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 0x574b
movq 0x50(%r15), %rdi
xorl %esi, %esi
callq 0x1a6da
jmp 0x1e942
orb $0x8, %bpl
movzbl %bpl, %esi
movq %r14, %rdi
callq 0x202c7
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x7f, %esi
jne 0x1e969
movq %r14, %rdi
callq 0x1fb1c
jmp 0x1e942
movq %r14, %rdi
xorl %esi, %esi
jmp 0x1e985
movq %r14, %rdi
callq 0x1f08f
jmp 0x1e942
movq %r14, %rdi
callq 0x20877
jmp 0x1e942
movq %r14, %rdi
movl $0x7fff, %esi           # imm = 0x7FFF
callq 0x1f5c6
jmp 0x1e942
movq %r14, %rdi
callq 0x208ab
jmp 0x1e942
movq %r14, %rdi
callq 0x208e6
jmp 0x1e942