Use labels in buffered goto command

The page labels are now used in the buffered command bcmd_goto, so
if this option is enabled and you try to reach page number 20, zathura
first seraches for a label named like that and moves to that page instead
of moving to page 20 in the document.
This commit is contained in:
Moritz Lipp 2010-05-05 12:51:18 +02:00
parent 52b4eb464f
commit 5e45c8d608

View file

@ -2761,7 +2761,21 @@ bcmd_goto(char* buffer, Argument* argument)
else if(!strcmp(buffer, "G"))
set_page(Zathura.PDF.number_of_pages - 1);
else
set_page(atoi(g_strndup(buffer, b_length - 1)) - 1);
{
char* id = g_strndup(buffer, b_length - 1);
int pid = atoi(id);
if(Zathura.Global.enable_labels)
{
int i;
for(i = 0; i < Zathura.PDF.number_of_pages; i++)
if(!strcmp(id, Zathura.PDF.pages[i]->label))
pid = Zathura.PDF.pages[i]->id;
}
set_page(pid - 1);
g_free(id);
}
update_status();
}