// File: phillip-h[P]todo/src/draw.cpp
// Function: Draw::init()
void Draw::init()
{
    std::cout << "\033]0;" << "todo" << "\7" << std::flush; 
    initscr();
    raw();
    
    use_default_colors();
    if (useColors() && has_colors()){
        start_color();
        init_pair(TITLE_COLOR_PAIR, TITLE_FOREGROUND, TITLE_BACKGROUND);
        init_pair(GUTTER_COLOR_PAIR, GUTTER_FOREGROUND, GUTTER_BACKGROUND);
        init_pair(SELECT_COLOR_PAIR, SELECT_FOREGROUND, SELECT_BACKGROUND);
        init_pair(BORDER_COLOR_PAIR, BORDER_FOREGROUND, BORDER_BACKGROUND);
        init_pair(MARK_COLOR_PAIR, MARK_FOREGROUND, MARK_BACKGROUND);
        init_pair(MARK_COLOR_PAIR_DONE, MARK_FOREGROUND_DONE, 
                  MARK_BACKGROUND_DONE);
        colors = true;
    }
    Win::setColors(colors);
    
    mouseinterval(0);    
    keypad(stdscr, true);
    noecho();

    clear();
    refresh();

    curs_set(0);

    startX = listStartX;
    startY = listStartY;
    width = COLS - startX - 2;
    height = LINES * listHeight;

    int inHeight = inputHeight * LINES;
    inHeight = std::max(inHeight, 4);

    titleWin = new Win(0, 0, COLS, titleHeight, "title", false);
    taskWin = new Win(startX, startY, width, height, "tasks");
    controlWin = new Win(inputStartX, inputStartY, COLS - inputStartX - 2, 
                         inHeight, "controls");
    inputWin = new Win(inputStartX, inputStartY, COLS - inputStartX - 2, 
                         inHeight, "new task");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq 0xd7c6(%rip), %rdi      # 0x17fc8
leaq 0x7c3b(%rip), %rsi      # 0x12444
callq 0x4340
movq %rax, %rdi
leaq 0x77fb(%rip), %rsi      # 0x12013
callq 0x4340
movq %rax, %rdi
leaq 0x7c22(%rip), %rsi      # 0x12449
callq 0x4340
movq %rax, %rdi
movq 0xd79a(%rip), %rsi      # 0x17fd0
callq 0x43a0
callq 0x4550
callq 0x4150
callq 0x4250
callq 0x82d0
testb $0x1, %al
jne 0xa858
jmp 0xa8e1
callq 0x45b0
testb $0x1, %al
jne 0xa863
jmp 0xa8e1
callq 0x40f0
movl $0x1, %edi
movl $0x4, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x40c0
movl $0x2, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %esi, %edi
callq 0x40c0
movl $0x3, %edi
movl $0x6, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x40c0
movl $0x4, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %esi, %edi
callq 0x40c0
movl $0x5, %edi
movl $0x1, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x40c0
movl $0x6, %edi
movl $0x2, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x40c0
movb $0x1, 0xde9b(%rip)      # 0x1877c
movzbl 0xde94(%rip), %edi      # 0x1877c
andl $0x1, %edi
callq 0x11ab0
xorl %edi, %edi
movl %edi, -0xdc(%rbp)
callq 0x45d0
movq 0xd6bc(%rip), %rax      # 0x17fc0
movq (%rax), %rdi
movl $0x1, %esi
callq 0x4180
callq 0x4420
callq 0x4670
callq 0x4650
movl -0xdc(%rbp), %edi
callq 0x42d0
movl $0x2, 0xde23(%rip)      # 0x18758
movl $0x6, 0xde1d(%rip)      # 0x1875c
movq 0xd65a(%rip), %rax      # 0x17fa0
movq %rax, -0xd8(%rbp)
movl (%rax), %eax
movl 0xde03(%rip), %ecx      # 0x18758
subl %ecx, %eax
addl $-0x2, %eax
movl %eax, 0xde00(%rip)      # 0x18760
movq 0xd631(%rip), %rax      # 0x17f98
cvtsi2ssl (%rax), %xmm0
movss 0x7ac9(%rip), %xmm1     # 0x1243c
mulss %xmm1, %xmm0
cvttss2si %xmm0, %ecx
movl %ecx, 0xdde3(%rip)      # 0x18764
cvtsi2ssl (%rax), %xmm0
movss 0x7ab3(%rip), %xmm1     # 0x12440
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x4(%rbp)
movl $0x4, -0x8(%rbp)
leaq -0x4(%rbp), %rdi
leaq -0x8(%rbp), %rsi
callq 0xc650
movl (%rax), %eax
movl %eax, -0x4(%rbp)
movl $0x40, %edi
callq 0x4350
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, -0xd0(%rbp)
movb $0x1, -0x3d(%rbp)
movl (%rax), %eax
movl %eax, -0xc4(%rbp)
leaq -0x29(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x4690
movq -0xc0(%rbp), %rdx
leaq 0x7a55(%rip), %rsi      # 0x1244b
leaq -0x28(%rbp), %rdi
callq 0x85c0
jmp 0xaa01
movl -0xc4(%rbp), %ecx
movq -0xd0(%rbp), %rdi
movq %rsp, %rax
movl $0x0, (%rax)
xorl %edx, %edx
movl $0x1, %r8d
leaq -0x28(%rbp), %r9
movl %edx, %esi
callq 0x11960
jmp 0xaa2c
movq -0xd0(%rbp), %rax
movb $0x0, -0x3d(%rbp)
movq %rax, 0xdcfa(%rip)      # 0x18738
leaq -0x28(%rbp), %rdi
callq 0x4738
leaq -0x29(%rbp), %rdi
callq 0x43d0
movl $0x40, %edi
callq 0x4350
movq %rax, -0x100(%rbp)
movb $0x1, -0x62(%rbp)
movl 0xdced(%rip), %eax      # 0x18758
movl %eax, -0xf8(%rbp)
movl 0xdce5(%rip), %eax      # 0x1875c
movl %eax, -0xf4(%rbp)
movl 0xdcdd(%rip), %eax      # 0x18760
movl %eax, -0xf0(%rbp)
movl 0xdcd5(%rip), %eax      # 0x18764
movl %eax, -0xec(%rbp)
leaq -0x61(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x4690
movq -0xe8(%rbp), %rdx
leaq 0x799e(%rip), %rsi      # 0x12451
leaq -0x60(%rbp), %rdi
callq 0x85c0
jmp 0xaabe
movl -0xec(%rbp), %r8d
movl -0xf0(%rbp), %ecx
movl -0xf4(%rbp), %edx
movl -0xf8(%rbp), %esi
movq -0x100(%rbp), %rdi
movq %rsp, %rax
movl $0x1, (%rax)
leaq -0x60(%rbp), %r9
callq 0x11960
jmp 0xaaf2
movq -0x100(%rbp), %rax
movb $0x0, -0x62(%rbp)
movq %rax, 0xdc3c(%rip)      # 0x18740
leaq -0x60(%rbp), %rdi
callq 0x4738
leaq -0x61(%rbp), %rdi
callq 0x43d0
movl $0x40, %edi
callq 0x4350
movq %rax, -0x118(%rbp)
movb $0x1, -0x8a(%rbp)
movq 0xd46b(%rip), %rax      # 0x17fa0
movl (%rax), %eax
addl $-0x4, %eax
movl %eax, -0x110(%rbp)
movl -0x4(%rbp), %eax
movl %eax, -0x10c(%rbp)
leaq -0x89(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x4690
movq -0x108(%rbp), %rdx
leaq 0x78ed(%rip), %rsi      # 0x12457
leaq -0x88(%rbp), %rdi
callq 0x85c0
jmp 0xab78
movl -0x10c(%rbp), %r8d
movl -0x110(%rbp), %ecx
movq -0x118(%rbp), %rdi
movq %rsp, %rax
movl $0x1, (%rax)
movl $0x2, %edx
leaq -0x88(%rbp), %r9
movl %edx, %esi
callq 0x11960
jmp 0xabaa
movq -0x118(%rbp), %rax
movb $0x0, -0x8a(%rbp)
movq %rax, 0xdb89(%rip)      # 0x18748
leaq -0x88(%rbp), %rdi
callq 0x4738
leaq -0x89(%rbp), %rdi
callq 0x43d0
movl $0x40, %edi
callq 0x4350
movq %rax, -0x130(%rbp)
movb $0x1, -0xb2(%rbp)
movq 0xd3aa(%rip), %rax      # 0x17fa0
movl (%rax), %eax
addl $-0x4, %eax
movl %eax, -0x128(%rbp)
movl -0x4(%rbp), %eax
movl %eax, -0x124(%rbp)
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x4690
movq -0x120(%rbp), %rdx
leaq 0x7835(%rip), %rsi      # 0x12460
leaq -0xb0(%rbp), %rdi
callq 0x85c0
jmp 0xac39
movl -0x124(%rbp), %r8d
movl -0x128(%rbp), %ecx
movq -0x130(%rbp), %rdi
movq %rsp, %rax
movl $0x1, (%rax)
movl $0x2, %edx
leaq -0xb0(%rbp), %r9
movl %edx, %esi
callq 0x11960
jmp 0xac6b
movq -0x130(%rbp), %rax
movb $0x0, -0xb2(%rbp)
movq %rax, 0xdad0(%rip)      # 0x18750
leaq -0xb0(%rbp), %rdi
callq 0x4738
leaq -0xb1(%rbp), %rdi
callq 0x43d0
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xacc4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x4738
leaq -0x29(%rbp), %rdi
callq 0x43d0
testb $0x1, -0x3d(%rbp)
jne 0xacd5
jmp 0xace6
movq -0xd0(%rbp), %rdi
movl $0x40, %esi
callq 0x4360
jmp 0xadd5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xad0e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x4738
leaq -0x61(%rbp), %rdi
callq 0x43d0
testb $0x1, -0x62(%rbp)
jne 0xad1f
jmp 0xad30
movq -0x100(%rbp), %rdi
movl $0x40, %esi
callq 0x4360
jmp 0xadd5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xad5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x4738
leaq -0x89(%rbp), %rdi
callq 0x43d0
testb $0x1, -0x8a(%rbp)
jne 0xad72
jmp 0xad83
movq -0x118(%rbp), %rdi
movl $0x40, %esi
callq 0x4360
jmp 0xadd5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xadab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x4738
leaq -0xb1(%rbp), %rdi
callq 0x43d0
testb $0x1, -0xb2(%rbp)
jne 0xadc2
jmp 0xadd3
movq -0x130(%rbp), %rdi
movl $0x40, %esi
callq 0x4360
jmp 0xadd5
movq -0x38(%rbp), %rdi
callq 0x4680
nop