// File: /workspace/github_c_makefile_star2_O3/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 0x9073d
leaq 0xf0(%rbx), %rdi
xorl %r14d, %r14d
xorl %esi, %esi
callq 0x55260
testb %al, %al
jne 0x90ac4
movq 0x648(%rbx), %r14
testq %r14, %r14
jne 0x90765
movl $0x6b8, %edi            # imm = 0x6B8
callq 0x556b0
movq %rax, %r14
movq %rax, %rdi
callq 0x58d00
movq %r14, 0x648(%rbx)
movq (%r14), %rax
movq %r14, %rdi
callq *0x168(%rax)
movq 0x648(%rbx), %r14
movq 0xdac69(%rip), %rbp     # 0x16b3e8
movq (%rbp), %r15
leaq 0x6668b(%rip), %rsi     # 0xf6e15
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 0x6661d(%rip), %rsi     # 0xf6e1a
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 0x82aff(%rip), %rsi     # 0x113342
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 0x66595(%rip), %rsi     # 0xf6e1e
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 0x66554(%rip), %rsi     # 0xf6e24
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 0x664ea(%rip), %rsi     # 0xf6e2a
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 0xdab3e(%rip), %rsi     # 0x16b4c8
xorl %edx, %edx
movq %rbx, %rcx
callq 0x94d7e
movq 0x20(%rsp), %rdi
addq %r12, %rdi
movq 0xdb245(%rip), %rsi     # 0x16bbe8
xorl %edx, %edx
movq %rbx, %rcx
callq 0x94d7e
movq 0x28(%rsp), %rax
leaq (%rax,%r12), %rdi
movq 0xdb3e3(%rip), %rsi     # 0x16bda0
xorl %edx, %edx
movq %rbx, %rcx
callq 0x94d7e
leaq (%r12,%r13), %rdi
movq 0xdab4e(%rip), %rsi     # 0x16b520
xorl %edx, %edx
movq %rbx, %rcx
callq 0x94d7e
movq %rbp, %rdi
addq %r12, %rdi
movq 0xdb467(%rip), %rsi     # 0x16be50
xorl %edx, %edx
movq %rbx, %rcx
callq 0x94d7e
addq %r14, %r12
movq 0xdb2b3(%rip), %rsi     # 0x16bcb0
movq %r12, %rdi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x94f5c
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x98(%rax)
testb %al, %al
jne 0x90a42
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 0x90a76
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 0x90a90
movl 0x5cc(%rbx), %ebp
leaq 0xf0(%rbx), %rdi
callq 0x57180
cmpl %eax, %ebp
je 0x90aa2
leaq 0xf0(%rbx), %rdi
xorl %esi, %esi
callq 0x55260
testb %al, %al
je 0x90aab
movq (%r14), %rax
movq %r14, %rdi
callq *0x70(%rax)
cmpl $0x1, 0x700(%rbx)
jne 0x90abd
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 0x90b03
jmp 0x90af6
jmp 0x90af6
jmp 0x90af6
jmp 0x90af6
jmp 0x90af6
jmp 0x90af6
jmp 0x90af6
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x59200
movq %rbx, %rdi
callq 0x57090
nop