// File: Linkerist[P]xs/src/ui.cc
// Function: display_list()
void
display_list(void)
{
 char description_format[40];
 vector<pair<string, string> > list;

 if (mode == LIST) {
  // if the list contains just one entry (probably due to filtering by giving a Needle)
  // we are done.
  if (default_list.size() == 1 && !opt_no_resolve)
   finish(current_entry(), true);
  else
   list = default_list;
 } else
  list = cur_list;

 clear();

 update_modeline();

 int pos = display_area_ymin;
 if (CurrPosition > static_cast<int>(list.size()) - 1)
  CurrPosition = list.size() - 1;

 // Calculate actual maxlength of descriptions so we can eliminate trailing blanks.
 // We have to iterate thru the list to get the longest description
 unsigned int actual_maxlength = 0;
 if(mode == LIST) {
  for (listit li = list.begin() + yoffset; li != list.end(); ++li) {
   if (strlen(li->first.c_str()) > actual_maxlength)
	actual_maxlength = strlen(li->first.c_str());

   // Don't let actual_maxlength > DESCRIPTION_MAXLENGTH
   if ( actual_maxlength > DESCRIPTION_MAXLENGTH)
	actual_maxlength = DESCRIPTION_MAXLENGTH;
  }
 } else
  actual_maxlength = DESCRIPTION_BROWSELENGTH;

 string cwd  = get_cwd_as_string();

 for (listit li = list.begin() + yoffset; li != list.end(); ++li) {
  //string desc = li->first.substr(0, (DESCRIPTION_MAXLENGTH + 1));
  string desc = li->first.substr(0, actual_maxlength);
  string path = li->second.substr(0, xmax - 16);
  string fullpath = li->second;
  char validmarker = ' ';

  if(!valid(fullpath, PATH_IS_DIR))
   validmarker = '!';

  if (pos > display_area_ymax)
   break;

  move(pos, 0);

  if (pos == CurrPosition - yoffset)
   attron(A_STANDOUT);

  if (fullpath == cwd)
   attron(A_BOLD);

  if (pos >= shorties_offset && pos < 10 + shorties_offset)
   printw("%2d", pos - shorties_offset);
  else
   printw("  ");

  // Compose format string for printw. Notice %% to represent literal %
  sprintf(description_format, " [%%-%ds] %%c%%s", actual_maxlength);

  printw(description_format, desc.c_str(), validmarker,path.c_str());

  if (pos == CurrPosition - yoffset)
   attroff(A_STANDOUT);

  if (fullpath == cwd)
   attroff(A_BOLD);

  pos++;
 }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
leaq -0x48(%rbp), %rdi
callq 0x5d80
leaq 0x8d4d(%rip), %rax      # 0x17598
cmpl $0x0, (%rax)
jne 0xe8d9
leaq 0x8ce5(%rip), %rdi      # 0x17540
callq 0x61f0
cmpq $0x1, %rax
jne 0xe8c3
leaq 0x8d31(%rip), %rax      # 0x1759e
testb $0x1, (%rax)
jne 0xe8c3
leaq -0x68(%rbp), %rdi
callq 0x8200
jmp 0xe87d
leaq -0x68(%rbp), %rdi
movl $0x1, %esi
callq 0x53d0
jmp 0xe88d
leaq -0x68(%rbp), %rdi
callq 0x4828
jmp 0xe8d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xee13
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x4828
jmp 0xee13
leaq 0x8c76(%rip), %rsi      # 0x17540
leaq -0x48(%rbp), %rdi
callq 0xf200
jmp 0xe8d5
jmp 0xe8d7
jmp 0xe8ed
leaq 0x8c48(%rip), %rsi      # 0x17528
leaq -0x48(%rbp), %rdi
callq 0xf200
jmp 0xe8eb
jmp 0xe8ed
callq 0x4720
jmp 0xe8f4
callq 0xefe0
jmp 0xe8fb
movl 0x8d1f(%rip), %eax      # 0x17620
movl %eax, -0x78(%rbp)
leaq 0x8c59(%rip), %rax      # 0x17564
movl (%rax), %eax
movl %eax, -0x160(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x61f0
movq %rax, %rcx
movl -0x160(%rbp), %eax
subl $0x1, %ecx
cmpl %ecx, %eax
jle 0xe944
leaq -0x48(%rbp), %rdi
callq 0x61f0
subq $0x1, %rax
movl %eax, %ecx
leaq 0x8c22(%rip), %rax      # 0x17564
movl %ecx, (%rax)
movl $0x0, -0x7c(%rbp)
leaq 0x8c46(%rip), %rax      # 0x17598
cmpl $0x0, (%rax)
jne 0xea13
leaq -0x48(%rbp), %rdi
callq 0x8c20
movq %rax, -0x90(%rbp)
movslq 0x8cba(%rip), %rsi      # 0x1762c
leaq -0x90(%rbp), %rdi
callq 0xa1b0
movq %rax, -0x88(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x8c50
movq %rax, -0x98(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x8dc0
testb $0x1, %al
jne 0xe9ae
jmp 0xea11
leaq -0x88(%rbp), %rdi
callq 0x8e00
movq %rax, %rdi
callq 0x41a0
movq %rax, %rdi
callq 0x41c0
movl -0x7c(%rbp), %ecx
cmpq %rcx, %rax
jbe 0xe9f1
leaq -0x88(%rbp), %rdi
callq 0x8e00
movq %rax, %rdi
callq 0x41a0
movq %rax, %rdi
callq 0x41c0
movl %eax, -0x7c(%rbp)
cmpl $0x12, -0x7c(%rbp)
jbe 0xe9fe
movl $0x12, -0x7c(%rbp)
jmp 0xea00
leaq -0x88(%rbp), %rdi
callq 0x8e20
jmp 0xe985
jmp 0xea1a
movl $0x8, -0x7c(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x51b0
jmp 0xea28
leaq -0x48(%rbp), %rdi
callq 0x8c20
movq %rax, -0xc8(%rbp)
movslq 0x8bed(%rip), %rsi      # 0x1762c
leaq -0xc8(%rbp), %rdi
callq 0xa1b0
movq %rax, -0xc0(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x8c50
movq %rax, -0xd0(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x8dc0
testb $0x1, %al
jne 0xea7e
jmp 0xede9
leaq -0xc0(%rbp), %rdi
callq 0x8e00
movq %rax, %rsi
movl -0x7c(%rbp), %eax
movl %eax, %ecx
xorl %eax, %eax
movl %eax, %edx
leaq -0xf0(%rbp), %rdi
callq 0x4400
jmp 0xeaa4
leaq -0xc0(%rbp), %rdi
callq 0x8e00
movq %rax, %rsi
addq $0x20, %rsi
movl 0x8b5b(%rip), %eax      # 0x17618
addl $-0x10, %eax
movslq %eax, %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0x110(%rbp), %rdi
callq 0x4400
jmp 0xead5
leaq -0xc0(%rbp), %rdi
callq 0x8e00
movq %rax, %rsi
addq $0x20, %rsi
leaq -0x130(%rbp), %rdi
callq 0x41b0
jmp 0xeaf6
movb $0x20, -0x131(%rbp)
leaq -0x158(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x41b0
jmp 0xeb12
leaq -0x158(%rbp), %rdi
movl $0x1, %esi
callq 0x52a0
movb %al, -0x161(%rbp)
jmp 0xeb2b
movb -0x161(%rbp), %al
xorb $-0x1, %al
movb %al, -0x162(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x4828
movb -0x162(%rbp), %al
testb $0x1, %al
jne 0xeb51
jmp 0xebbb
movb $0x21, -0x131(%rbp)
jmp 0xebbb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xee07
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xeddb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xedcf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0xedc3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x4828
jmp 0xedc3
movl -0x78(%rbp), %eax
cmpl 0x8a58(%rip), %eax      # 0x1761c
jle 0xebd5
movl $0x5, -0x15c(%rbp)
jmp 0xed7e
movl -0x78(%rbp), %edi
xorl %esi, %esi
callq 0x42d0
jmp 0xebe1
movl -0x78(%rbp), %eax
leaq 0x8979(%rip), %rcx      # 0x17564
movl (%rcx), %ecx
subl 0x8a39(%rip), %ecx      # 0x1762c
cmpl %ecx, %eax
jne 0xec13
movq 0x83c2(%rip), %rax      # 0x16fc0
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %edx
movl $0x10000, %esi          # imm = 0x10000
callq 0x4200
jmp 0xec11
jmp 0xec13
leaq -0x130(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x8a20
testb $0x1, %al
jne 0xec2c
jmp 0xec48
movq 0x838d(%rip), %rax      # 0x16fc0
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %edx
movl $0x200000, %esi         # imm = 0x200000
callq 0x4200
jmp 0xec46
jmp 0xec48
movl -0x78(%rbp), %eax
cmpl 0x89e3(%rip), %eax      # 0x17634
jl 0xec80
movl -0x78(%rbp), %eax
movl 0x89d8(%rip), %ecx      # 0x17634
addl $0xa, %ecx
cmpl %ecx, %eax
jge 0xec80
movl -0x78(%rbp), %esi
movl 0x89c8(%rip), %eax      # 0x17634
subl %eax, %esi
leaq 0x213e(%rip), %rdi      # 0x10db3
xorl %eax, %eax
callq 0x43e0
jmp 0xec7e
jmp 0xec92
leaq 0x23ed(%rip), %rdi      # 0x11074
xorl %eax, %eax
callq 0x43e0
jmp 0xec90
jmp 0xec92
movl -0x7c(%rbp), %edx
leaq 0x211b(%rip), %rsi      # 0x10db7
xorl %eax, %eax
movb %al, -0x163(%rbp)
leaq -0x30(%rbp), %rdi
movq %rdi, -0x178(%rbp)
callq 0x40a0
leaq -0xf0(%rbp), %rdi
callq 0x41a0
movq %rax, -0x170(%rbp)
movsbl -0x131(%rbp), %eax
movl %eax, -0x168(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x41a0
movq -0x178(%rbp), %rdi
movq -0x170(%rbp), %rsi
movl -0x168(%rbp), %edx
movq %rax, %rcx
movb -0x163(%rbp), %al
callq 0x43e0
jmp 0xed04
movl -0x78(%rbp), %eax
leaq 0x8856(%rip), %rcx      # 0x17564
movl (%rcx), %ecx
subl 0x8916(%rip), %ecx      # 0x1762c
cmpl %ecx, %eax
jne 0xed36
movq 0x829f(%rip), %rax      # 0x16fc0
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %edx
movl $0x10000, %esi          # imm = 0x10000
callq 0x4520
jmp 0xed34
jmp 0xed36
leaq -0x130(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x8a20
testb $0x1, %al
jne 0xed4f
jmp 0xed6b
movq 0x826a(%rip), %rax      # 0x16fc0
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %edx
movl $0x200000, %esi         # imm = 0x200000
callq 0x4520
jmp 0xed69
jmp 0xed6b
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
movl $0x0, -0x15c(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x4828
leaq -0x110(%rbp), %rdi
callq 0x4828
leaq -0xf0(%rbp), %rdi
callq 0x4828
movl -0x15c(%rbp), %eax
testl %eax, %eax
je 0xedb0
jmp 0xedae
jmp 0xede9
jmp 0xedb2
leaq -0xc0(%rbp), %rdi
callq 0x8e20
jmp 0xea52
leaq -0x130(%rbp), %rdi
callq 0x4828
leaq -0x110(%rbp), %rdi
callq 0x4828
leaq -0xf0(%rbp), %rdi
callq 0x4828
jmp 0xee07
leaq -0xb8(%rbp), %rdi
callq 0x4828
leaq -0x48(%rbp), %rdi
callq 0x5da0
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
leaq -0xb8(%rbp), %rdi
callq 0x4828
leaq -0x48(%rbp), %rdi
callq 0x5da0
movq -0x70(%rbp), %rdi
callq 0x4730
nopw %cs:(%rax,%rax)