// File: /workspace/github_c_makefile_star2_O1/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 *0x425ee(%rip)          # 0x603e8
movl %eax, %ebx
cmpb $0x1, %al
jne 0x1e151
cmpb $0x7, %bpl
jne 0x1de27
leaq 0x21a95(%rip), %rsi     # 0x3f8a6
movq %r12, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6bf5
movq %r14, %rdi
callq 0x6ad8
cmpb $0x13, %bpl
ja 0x1e151
movq %rax, %r15
movzbl %bpl, %esi
leaq 0x219ad(%rip), %rax     # 0x3f7f4
movslq (%rax,%rsi,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq %r14, %rdi
movq %r12, %rdx
callq 0x202fb
jmp 0x1e151
movq %r14, %rdi
callq 0x1ff1f
orb $0x8, %al
movzbl %al, %esi
jmp 0x1e149
movb $0x1, (%r12)
jmp 0x1e151
movq 0x60(%r15), %rdi
testq %rdi, %rdi
je 0x1e151
callq 0x29984
jmp 0x1e151
cmpq $0x0, 0x50(%r15)
je 0x1e151
movq %r14, %rdi
callq 0x26288
movq %rax, %r12
movq %r14, %rdi
callq 0x6697
movq %rax, %r13
movq %r12, %rdi
callq 0x6697
movq %rax, %r12
testb $0x2, 0x98(%r15)
movq 0x50(%r15), %rbp
jne 0x1e0f5
movq %r14, %rdi
callq 0x2641d
movswl %ax, %esi
movq %rbp, %rdi
callq 0x56f1
movq 0x50(%r15), %rdi
movswl 0x1a(%r12), %esi
movswl 0x1c(%r12), %edx
callq 0x4ae2
movq 0x58(%r15), %r13
testq %r13, %r13
je 0x1e134
movq %r14, %rdi
callq 0x2641d
movswl %ax, %esi
movq %r13, %rdi
callq 0x56f1
movq 0x58(%r15), %rdi
movswl 0x1a(%r12), %esi
movswl 0x16(%r12), %edx
callq 0x4ae2
jmp 0x1e134
cmpq $0x0, 0x50(%r15)
je 0x1dfc3
movq %r14, %rdi
callq 0x5651
movzwl 0x4(%r12), %ecx
subw (%r12), %cx
incl %ecx
cmpw %cx, %ax
jne 0x1df73
movq %r14, %rdi
callq 0x567b
movzwl 0x6(%r12), %ecx
subw 0x2(%r12), %cx
incl %ecx
cmpw %cx, %ax
je 0x1dfc3
movq %r14, %rdi
callq 0x26288
movq %rax, %rdi
callq 0x6697
movq %rax, %r13
movq 0x50(%r15), %rbp
movq %r14, %rdi
callq 0x2641d
movswl %ax, %esi
movq %rbp, %rdi
callq 0x56f1
movq 0x50(%r15), %rdi
movswl 0x1a(%r13), %esi
movswl 0x16(%r13), %edx
callq 0x4ae2
movq 0x50(%r15), %rdi
xorl %esi, %esi
callq 0x19f13
movq %r14, %rdi
callq 0x1f77a
cmpq $0x0, 0x58(%r15)
je 0x1e151
movq %r14, %rdi
callq 0x5651
movzwl 0x4(%r12), %ecx
subw (%r12), %cx
incl %ecx
cmpw %cx, %ax
jne 0x1e007
movq %r14, %rdi
callq 0x567b
movzwl 0x6(%r12), %ecx
subw 0x2(%r12), %cx
incl %ecx
cmpw %cx, %ax
je 0x1e151
movq %r14, %rdi
callq 0x26288
movq %rax, %rdi
callq 0x6697
movq %rax, %r12
movq 0x58(%r15), %r13
movq %r14, %rdi
callq 0x2641d
movswl %ax, %esi
movq %r13, %rdi
callq 0x56f1
movq 0x58(%r15), %rdi
movswl 0x1a(%r12), %esi
movswl 0x16(%r12), %edx
callq 0x4ae2
movq 0x58(%r15), %rdi
xorl %esi, %esi
callq 0x19f13
movq %r14, %rdi
callq 0x1f77a
jmp 0x1e151
movq %r14, %rdi
callq 0x1ff1f
movl %eax, %ebp
movq %r14, %rdi
callq 0x4ea3
movq %rax, %rdi
callq 0x2b2b
movl %eax, %r15d
callq 0x3784
movq %rax, %rdi
callq 0x378c
cmpb $0x4, %al
jne 0x1e095
testb %r15b, %r15b
je 0x1e141
andb $0x7, %bpl
jmp 0x1e145
movl (%r12), %esi
cmpl $0x10, %esi
jle 0x1e0d0
leal -0x11(%rsi), %eax
cmpl $0x3, %eax
ja 0x1e162
leaq 0x2178a(%rip), %rcx     # 0x3f844
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r14, %rdi
callq 0x201bd
jmp 0x1e151
cmpl $0x2, %esi
je 0x1e171
cmpl $0x3, %esi
je 0x1e18c
cmpl $0x8, %esi
jne 0x1e178
movq %r14, %rdi
callq 0x1f16a
jmp 0x1e151
movq %rbp, %rdi
callq 0x6697
movq 0x28(%rax), %rax
movzbl 0x10(%rax), %ebp
movq 0x50(%r15), %rdi
movl %ebp, %esi
callq 0x572f
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 0x572f
movq 0x50(%r15), %rdi
xorl %esi, %esi
callq 0x19f13
jmp 0x1e151
orb $0x8, %bpl
movzbl %bpl, %esi
movq %r14, %rdi
callq 0x1fad3
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x7f, %esi
jne 0x1e178
movq %r14, %rdi
callq 0x1f33e
jmp 0x1e151
movq %r14, %rdi
xorl %esi, %esi
jmp 0x1e194
movq %r14, %rdi
callq 0x1e89b
jmp 0x1e151
movq %r14, %rdi
callq 0x20083
jmp 0x1e151
movq %r14, %rdi
movl $0x7fff, %esi           # imm = 0x7FFF
callq 0x1edf8
jmp 0x1e151
movq %r14, %rdi
callq 0x200b7
jmp 0x1e151
movq %r14, %rdi
callq 0x200f2
jmp 0x1e151