// File: JD297[P]cedit/src/menu.cpp
// Function: cedit::Menu::type(char const*, char const*)
[[nodiscard]] bool Menu::type(const char* text, const char* content) {
    this->content = content;
    this->currentIndex = 0;

    while(true) {

        this->display_type(text);

        this->key = wgetch(this->window);

        switch(this->key) {
            case 10:
                wbkgd(this->window, A_NORMAL);
				this->window_clear_refresh();

                return this->content.length() > 0;
            break;
            case 3: // abort strg+c
                wbkgd(this->window, A_NORMAL);
                this->window_clear_refresh();

                return false;
            break;
            case KEY_LEFT:
                this->event_left();
            break;
            case KEY_RIGHT:
                this->event_right();
            break;
            case KEY_BACKSPACE:
                this->event_backspace();
            break;
            case KEY_DC:
                this->event_delete();
            break;
            case KEY_HOME:
                this->event_pos_1();
            break;
            case KEY_END:
                this->event_pos_end();
            break;
            default:
                this->event_insert();
            break;
        }
    }

    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x28(%rbp)
movq -0x20(%rbp), %rsi
addq $0x18, %rdi
callq 0x45c0
movq -0x28(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xd6a0
movq -0x28(%rbp), %rax
movq (%rax), %rdi
callq 0x41d0
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x40(%rax)
movl 0x40(%rax), %eax
movl %eax, -0x2c(%rbp)
subl $0x3, %eax
je 0xda17
jmp 0xd978
movl -0x2c(%rbp), %eax
subl $0xa, %eax
je 0xd9e5
jmp 0xd982
movl -0x2c(%rbp), %eax
subl $0x104, %eax            # imm = 0x104
je 0xda34
jmp 0xd992
movl -0x2c(%rbp), %eax
subl $0x105, %eax            # imm = 0x105
je 0xda3f
jmp 0xd9a2
movl -0x2c(%rbp), %eax
subl $0x106, %eax            # imm = 0x106
je 0xda60
jmp 0xd9b2
movl -0x2c(%rbp), %eax
subl $0x107, %eax            # imm = 0x107
je 0xda4a
jmp 0xd9c2
movl -0x2c(%rbp), %eax
subl $0x14a, %eax            # imm = 0x14A
je 0xda55
jmp 0xd9d2
movl -0x2c(%rbp), %eax
subl $0x168, %eax            # imm = 0x168
je 0xda6b
jmp 0xda76
movq -0x28(%rbp), %rax
movq (%rax), %rdi
xorl %esi, %esi
callq 0x46d0
movq -0x28(%rbp), %rdi
callq 0xdc70
movq -0x28(%rbp), %rdi
addq $0x18, %rdi
callq 0x4640
cmpq $0x0, %rax
seta %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0xda84
movq -0x28(%rbp), %rax
movq (%rax), %rdi
xorl %esi, %esi
callq 0x46d0
movq -0x28(%rbp), %rdi
callq 0xdc70
movb $0x0, -0x1(%rbp)
jmp 0xda84
movq -0x28(%rbp), %rdi
callq 0xd7b0
jmp 0xda7f
movq -0x28(%rbp), %rdi
callq 0xd7e0
jmp 0xda7f
movq -0x28(%rbp), %rdi
callq 0xd820
jmp 0xda7f
movq -0x28(%rbp), %rdi
callq 0xd870
jmp 0xda7f
movq -0x28(%rbp), %rdi
callq 0xd8c0
jmp 0xda7f
movq -0x28(%rbp), %rdi
callq 0xd8e0
jmp 0xda7f
movq -0x28(%rbp), %rdi
callq 0xd750
jmp 0xd945
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x30, %rsp
popq %rbp
retq
nop