// File: /workspace/github_c_makefile_star2_O2/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 0x8d2a1
leaq 0xf0(%rbx), %rdi
xorl %r14d, %r14d
xorl %esi, %esi
callq 0x56280
testb %al, %al
jne 0x8d628
movq 0x648(%rbx), %r14
testq %r14, %r14
jne 0x8d2c9
movl $0x6b8, %edi            # imm = 0x6B8
callq 0x56700
movq %rax, %r14
movq %rax, %rdi
callq 0x5a050
movq %r14, 0x648(%rbx)
movq (%r14), %rax
movq %r14, %rdi
callq *0x168(%rax)
movq 0x648(%rbx), %r14
movq 0xd4105(%rip), %rbp     # 0x1613e8
movq (%rbp), %r15
leaq 0x59a27(%rip), %rsi     # 0xe6d15
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x58c40
movq %r15, %rdi
movq %r12, %rsi
callq 0x59510
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x569f0
movq %rax, 0x30(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x5a588
movq 0x648(%rbx), %r14
leaq 0x8(%rsp), %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x5a180
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x569f0
leaq 0x8(%rsp), %rdi
callq 0x5a588
movq 0x648(%rbx), %r14
movq (%rbp), %r15
leaq 0x599b9(%rip), %rsi     # 0xe6d1a
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x58c40
movq %r15, %rdi
movq %r12, %rsi
callq 0x59510
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x569f0
movq %rax, 0x20(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x5a588
movq 0x648(%rbx), %r14
movq (%rbp), %r12
leaq 0x75e7b(%rip), %rsi     # 0x103222
leaq 0x8(%rsp), %r13
movq %r13, %rdi
callq 0x58c40
movq %r12, %rdi
movq %r13, %rsi
callq 0x59510
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x569f0
movq %rax, 0x28(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x5a588
movq 0x648(%rbx), %r14
movq (%rbp), %r12
leaq 0x59931(%rip), %rsi     # 0xe6d1e
leaq 0x8(%rsp), %r13
movq %r13, %rdi
callq 0x58c40
movq %r12, %rdi
movq %r13, %rsi
callq 0x59510
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x569f0
movq %rax, %r13
leaq 0x8(%rsp), %rdi
callq 0x5a588
movq 0x648(%rbx), %r14
movq %rbp, %r15
movq (%rbp), %r12
leaq 0x598f0(%rip), %rsi     # 0xe6d24
leaq 0x8(%rsp), %rbp
movq %rbp, %rdi
callq 0x58c40
movq %r12, %rdi
movq %rbp, %rsi
callq 0x59510
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x569f0
movq %rax, %rbp
leaq 0x8(%rsp), %rdi
callq 0x5a588
movq 0x648(%rbx), %r14
leaq 0x8(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x5a180
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x569f0
leaq 0x8(%rsp), %rdi
callq 0x5a588
movq 0x648(%rbx), %r14
movq (%r15), %r12
leaq 0x59886(%rip), %rsi     # 0xe6d2a
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x58c40
movq %r12, %rdi
movq %r15, %rsi
callq 0x59510
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x569f0
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x5a588
movl $0x478, %r12d           # imm = 0x478
movq 0x30(%rsp), %r15
movq %r15, %rdi
addq %r12, %rdi
movq 0xd3fda(%rip), %rsi     # 0x1614c8
xorl %edx, %edx
movq %rbx, %rcx
callq 0x91462
movq 0x20(%rsp), %rdi
addq %r12, %rdi
movq 0xd46e1(%rip), %rsi     # 0x161be8
xorl %edx, %edx
movq %rbx, %rcx
callq 0x91462
movq 0x28(%rsp), %rax
leaq (%rax,%r12), %rdi
movq 0xd487f(%rip), %rsi     # 0x161da0
xorl %edx, %edx
movq %rbx, %rcx
callq 0x91462
leaq (%r12,%r13), %rdi
movq 0xd3fea(%rip), %rsi     # 0x161520
xorl %edx, %edx
movq %rbx, %rcx
callq 0x91462
movq %rbp, %rdi
addq %r12, %rdi
movq 0xd4903(%rip), %rsi     # 0x161e50
xorl %edx, %edx
movq %rbx, %rcx
callq 0x91462
addq %r14, %r12
movq 0xd474f(%rip), %rsi     # 0x161cb0
movq %r12, %rdi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x91620
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x98(%rax)
testb %al, %al
jne 0x8d5a6
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 0x8d5da
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)
movl 0x5c8(%rbx), %eax
testl %eax, %eax
jne 0x8d5f4
movl 0x5cc(%rbx), %ebp
leaq 0xf0(%rbx), %rdi
callq 0x58370
cmpl %eax, %ebp
je 0x8d606
leaq 0xf0(%rbx), %rdi
xorl %esi, %esi
callq 0x56280
testb %al, %al
je 0x8d60f
movq (%r14), %rax
movq %r14, %rdi
callq *0x70(%rax)
cmpl $0x1, 0x700(%rbx)
jne 0x8d621
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 0x564c0
jmp 0x8d667
jmp 0x8d65a
jmp 0x8d65a
jmp 0x8d65a
jmp 0x8d65a
jmp 0x8d65a
jmp 0x8d65a
jmp 0x8d65a
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x5a588
movq %rbx, %rdi
callq 0x58260
nop