From 5e45c8d6082d938ce426f35d46da074b54ce920e Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Wed, 5 May 2010 12:51:18 +0200 Subject: [PATCH] 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. --- zathura.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/zathura.c b/zathura.c index 65468b6..e277c6e 100644 --- a/zathura.c +++ b/zathura.c @@ -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(); }