// File: /workspace/github_c_makefile_star2_O1/enzo1982[P]smooth/classes/gui/widgets/special/cursor.cpp
// Function: smooth::GUI::Cursor::GetContextMenu()
S::GUI::PopupMenu *S::GUI::Cursor::GetContextMenu()
{
	if (!IsActive() && text == NIL) return NIL;

	if (contextMenu == NIL) contextMenu = new PopupMenu();

	contextMenu->RemoveAllEntries();

	MenuEntry	*entryUndo    = contextMenu->AddEntry(I18n::Translator::defaultTranslator->TranslateString("Undo"));

	contextMenu->AddEntry();

	MenuEntry	*entryCut     = contextMenu->AddEntry(I18n::Translator::defaultTranslator->TranslateString("Cut"));
	MenuEntry	*entryCopy    = contextMenu->AddEntry(I18n::Translator::defaultTranslator->TranslateString("Copy"));
	MenuEntry	*entryInsert  = contextMenu->AddEntry(I18n::Translator::defaultTranslator->TranslateString("Paste"));
	MenuEntry	*entryDelete  = contextMenu->AddEntry(I18n::Translator::defaultTranslator->TranslateString("Clear"));

	contextMenu->AddEntry();

	MenuEntry	*entryMarkAll = contextMenu->AddEntry(I18n::Translator::defaultTranslator->TranslateString("Select all"));

	entryUndo->onAction.Connect(&Cursor::Undo, this);

	entryCut->onAction.Connect(&Cursor::OnCut, this);
	entryCopy->onAction.Connect(&Cursor::CopyToClipboard, this);
	entryInsert->onAction.Connect(&Cursor::OnInsert, this);
	entryDelete->onAction.Connect(&Cursor::DeleteSelectedText, this);

	entryMarkAll->onAction.Connect(&Cursor::MarkAll, this);

	/* Disable modification if inactive.
	 */
	if (!IsActive())
	{
		entryUndo->Deactivate();
		entryCut->Deactivate();
		entryInsert->Deactivate();
		entryDelete->Deactivate();
	}

	/* Disable copy and delete if nothing is selected.
	 */
	if (markStart == markEnd)
	{
		entryCut->Deactivate();
		entryCopy->Deactivate();
		entryDelete->Deactivate();
	}

	/* Disable "Select all" if everything is selected already.
	 */
	if ((markStart == 0 && markEnd == text.Length()) || text == NIL)
	{
		entryMarkAll->Deactivate();
	}

	/* Disable undo if no history is available.
	 */
	if (historyPos == 1)
	{
		entryUndo->Deactivate();
	}

	return contextMenu;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movq (%rdi), %rax
callq *0x98(%rax)
testb %al, %al
jne 0x90ccd
leaq 0xf0(%rbx), %rdi
xorl %r14d, %r14d
xorl %esi, %esi
callq 0x55260
testb %al, %al
jne 0x91055
cmpq $0x0, 0x648(%rbx)
jne 0x90cf3
movl $0x6b8, %edi            # imm = 0x6B8
callq 0x556b0
movq %rax, %r14
movq %rax, %rdi
callq 0x58d00
movq %r14, 0x648(%rbx)
movq 0x648(%rbx), %rdi
movq (%rdi), %rax
callq *0x168(%rax)
movq 0x648(%rbx), %r14
movq 0xdb6d7(%rip), %rbp     # 0x16c3e8
movq (%rbp), %r15
leaq 0x66f55(%rip), %rsi     # 0xf7c71
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x579f0
movq %r15, %rdi
movq %r12, %rsi
callq 0x58260
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x55990
movq %rax, 0x30(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x59200
movq 0x648(%rbx), %r14
leaq 0x8(%rsp), %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x58e20
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x55990
leaq 0x8(%rsp), %rdi
callq 0x59200
movq 0x648(%rbx), %r14
movq (%rbp), %r15
leaq 0x66ee7(%rip), %rsi     # 0xf7c76
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x579f0
movq %r15, %rdi
movq %r12, %rsi
callq 0x58260
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x55990
movq %rax, 0x20(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x59200
movq 0x648(%rbx), %r14
movq (%rbp), %r12
leaq 0x83361(%rip), %rsi     # 0x114136
leaq 0x8(%rsp), %r13
movq %r13, %rdi
callq 0x579f0
movq %r12, %rdi
movq %r13, %rsi
callq 0x58260
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x55990
movq %rax, 0x28(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x59200
movq 0x648(%rbx), %r14
movq (%rbp), %r12
leaq 0x66e5f(%rip), %rsi     # 0xf7c7a
leaq 0x8(%rsp), %r13
movq %r13, %rdi
callq 0x579f0
movq %r12, %rdi
movq %r13, %rsi
callq 0x58260
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x55990
movq %rax, %r13
leaq 0x8(%rsp), %rdi
callq 0x59200
movq 0x648(%rbx), %r14
movq %rbp, %r15
movq (%rbp), %r12
leaq 0x66e1e(%rip), %rsi     # 0xf7c80
leaq 0x8(%rsp), %rbp
movq %rbp, %rdi
callq 0x579f0
movq %r12, %rdi
movq %rbp, %rsi
callq 0x58260
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x55990
movq %rax, %rbp
leaq 0x8(%rsp), %rdi
callq 0x59200
movq 0x648(%rbx), %r14
leaq 0x8(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x58e20
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x55990
leaq 0x8(%rsp), %rdi
callq 0x59200
movq 0x648(%rbx), %r14
movq (%r15), %r12
leaq 0x66db4(%rip), %rsi     # 0xf7c86
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x579f0
movq %r12, %rdi
movq %r15, %rsi
callq 0x58260
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x55990
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x59200
movl $0x478, %r12d           # imm = 0x478
movq 0x30(%rsp), %r15
movq %r15, %rdi
addq %r12, %rdi
movq 0xdb5ac(%rip), %rsi     # 0x16c4c8
xorl %edx, %edx
movq %rbx, %rcx
callq 0x953e4
movq 0x20(%rsp), %rdi
addq %r12, %rdi
movq 0xdbcb3(%rip), %rsi     # 0x16cbe8
xorl %edx, %edx
movq %rbx, %rcx
callq 0x953e4
movq 0x28(%rsp), %rax
leaq (%rax,%r12), %rdi
movq 0xdbe51(%rip), %rsi     # 0x16cda0
xorl %edx, %edx
movq %rbx, %rcx
callq 0x953e4
leaq (%r12,%r13), %rdi
movq 0xdb5bc(%rip), %rsi     # 0x16c520
xorl %edx, %edx
movq %rbx, %rcx
callq 0x953e4
movq %rbp, %rdi
addq %r12, %rdi
movq 0xdbed5(%rip), %rsi     # 0x16ce50
xorl %edx, %edx
movq %rbx, %rcx
callq 0x953e4
addq %r14, %r12
movq 0xdbd21(%rip), %rsi     # 0x16ccb0
movq %r12, %rdi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x955b6
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x98(%rax)
testb %al, %al
jne 0x90fd4
movq (%r15), %rax
movq %r15, %rdi
callq *0x70(%rax)
movq 0x20(%rsp), %rdi
movq (%rdi), %rax
callq *0x70(%rax)
movq (%r13), %rax
movq %r13, %rdi
callq *0x70(%rax)
movq (%rbp), %rax
movq %rbp, %rdi
callq *0x70(%rax)
movl 0x5c8(%rbx), %eax
cmpl 0x5cc(%rbx), %eax
jne 0x91002
movq 0x20(%rsp), %rdi
movq (%rdi), %rax
callq *0x70(%rax)
movq 0x28(%rsp), %rdi
movq (%rdi), %rax
callq *0x70(%rax)
movq (%rbp), %rax
movq %rbp, %rdi
callq *0x70(%rax)
cmpl $0x0, 0x5c8(%rbx)
jne 0x91021
movl 0x5cc(%rbx), %ebp
leaq 0xf0(%rbx), %rdi
callq 0x57180
cmpl %eax, %ebp
je 0x91033
leaq 0xf0(%rbx), %rdi
xorl %esi, %esi
callq 0x55260
testb %al, %al
je 0x9103c
movq (%r14), %rax
movq %r14, %rdi
callq *0x70(%rax)
cmpl $0x1, 0x700(%rbx)
jne 0x9104e
movq (%r15), %rax
movq %r15, %rdi
callq *0x70(%rax)
movq 0x648(%rbx), %r14
movq %r14, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0x6b8, %esi            # imm = 0x6B8
movq %r14, %rdi
callq 0x55480
jmp 0x91094
jmp 0x91087
jmp 0x91087
jmp 0x91087
jmp 0x91087
jmp 0x91087
jmp 0x91087
jmp 0x91087
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x59200
movq %rbx, %rdi
callq 0x57090