// File: JD297[P]cedit/src/cedit.cpp
// Function: cedit::Cedit::event_delete()
void Cedit::event_delete()
{
	// Last character and last row
	if(this->currentIndex == this->contentIt->length() && this->content.end() == std::next(this->contentIt))
	{
		return;
	}
	// Line end: copy next line to this line, delete next line
	else if(this->currentIndex == this->contentIt->length()-1 && this->contentIt->back() == '\n')
	{
		// If the line has more content then "\n" 
		if(std::next(this->contentIt)->length() != 1)
		{
			// Remove the paragraph
			this->contentIt->erase(this->currentIndex, 1);

			// Copy the entire next line to the current line
			this->contentIt->append(std::next(this->contentIt)->substr(0));

			// Delete the line from where the list was copied from
			this->content.erase(std::next(this->contentIt));
		}
		else if(std::next(this->contentIt)->length() == 1)
		{
			// Delete the next line
			this->content.erase(std::next(this->contentIt));
		}
	}
	else
	{
		// Delete character
		this->contentIt->erase(this->currentIndex, 1);
		this->refreshDisplay = false;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
movq 0x50(%rdi), %rax
movq %rax, -0xd0(%rbp)
addq $0x18, %rdi
callq 0x92f0
movq %rax, %rdi
callq 0x4640
movq -0xd0(%rbp), %rcx
movq %rax, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, -0xc1(%rbp)
jne 0x6214
movq -0xd8(%rbp), %rdi
callq 0x92c0
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, -0x10(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movl $0x1, %esi
callq 0x9d90
movq %rax, -0x18(%rbp)
leaq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x9e30
movb %al, -0xc1(%rbp)
movb -0xc1(%rbp), %al
testb $0x1, %al
jne 0x6220
jmp 0x6225
jmp 0x64b1
movq -0xd8(%rbp), %rdi
movq 0x50(%rdi), %rax
movq %rax, -0xe0(%rbp)
addq $0x18, %rdi
callq 0x92f0
movq %rax, %rdi
callq 0x4640
movq %rax, %rcx
movq -0xe0(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x647c
movq -0xd8(%rbp), %rdi
addq $0x18, %rdi
callq 0x92f0
movq %rax, %rdi
callq 0x4350
movsbl (%rax), %eax
cmpl $0xa, %eax
jne 0x647c
movq -0xd8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0x9d90
movq %rax, -0x28(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x92f0
movq %rax, %rdi
callq 0x4640
cmpq $0x1, %rax
je 0x63dd
movq -0xd8(%rbp), %rdi
addq $0x18, %rdi
movq %rdi, -0x100(%rbp)
callq 0x92f0
movq %rax, %rdi
movq -0xd8(%rbp), %rax
movq 0x50(%rax), %rsi
movl $0x1, %edx
movq %rdx, -0xf8(%rbp)
callq 0x4100
movq -0x100(%rbp), %rdi
callq 0x92f0
movq -0xf8(%rbp), %rsi
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq %rcx, -0xf0(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
callq 0x9d90
movq %rax, -0x58(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x92f0
movq %rax, %rsi
xorl %eax, %eax
movl %eax, %edx
leaq -0x50(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
movq $-0x1, %rcx
callq 0x4430
movq -0xf0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
callq 0x4760
jmp 0x636a
leaq -0x50(%rbp), %rdi
callq 0x42d0
movq -0xd8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
movl $0x1, %esi
callq 0x9d90
movq %rax, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x9dc0
movq -0xd8(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x9de0
movq %rax, -0x90(%rbp)
jmp 0x647a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x42d0
jmp 0x64ba
movq -0xd8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rdi
movl $0x1, %esi
callq 0x9d90
movq %rax, -0x98(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x92f0
movq %rax, %rdi
callq 0x4640
cmpq $0x1, %rax
jne 0x6478
movq -0xd8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rdi
movl $0x1, %esi
callq 0x9d90
movq %rax, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x9dc0
movq -0xd8(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x9de0
movq %rax, -0xc0(%rbp)
jmp 0x647a
jmp 0x64af
movq -0xd8(%rbp), %rdi
addq $0x18, %rdi
callq 0x92f0
movq %rax, %rdi
movq -0xd8(%rbp), %rax
movq 0x50(%rax), %rsi
movl $0x1, %edx
callq 0x4100
movq -0xd8(%rbp), %rax
movb $0x0, 0x6c(%rax)
jmp 0x64b1
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x4700
nopw %cs:(%rax,%rax)