From 727c0e9ee350aab625da8e55f66fa8af8e65dbbf Mon Sep 17 00:00:00 2001 From: neldoreth Date: Mon, 28 Dec 2009 18:34:00 +0100 Subject: [PATCH] Implemented buffer commands goto and zoom --- config.def.h | 5 +++-- zathura.c | 24 ++++++++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/config.def.h b/config.def.h index 1d0c92f..68c190e 100644 --- a/config.def.h +++ b/config.def.h @@ -1,6 +1,7 @@ /* settings */ -static const int DEFAULT_WIDTH = 800; -static const int DEFAULT_HEIGHT = 600; +static const int DEFAULT_WIDTH = 800; +static const int DEFAULT_HEIGHT = 600; +static const float ZOOM_STEP = 0.1; /* completion */ static const char FORMAT_COMMAND[] = "%s"; diff --git a/zathura.c b/zathura.c index ddb6fa9..3785a46 100644 --- a/zathura.c +++ b/zathura.c @@ -110,8 +110,6 @@ typedef struct { PopplerPage *page; cairo_surface_t *surface; - double scale; - int rotate; } Page; /* zathura */ @@ -171,6 +169,8 @@ struct Page *pages; int page_number; int number_of_pages; + double scale; + int rotate; } PDF; } Zathura; @@ -543,7 +543,7 @@ sc_navigate(Argument* argument) void sc_rotate(Argument* argument) { - + Zathura.PDF.rotate = (Zathura.PDF.rotate + 90) % 360; } void @@ -1058,13 +1058,29 @@ Completion* cc_open(char* input) void bcmd_goto(char* buffer, Argument* argument) { + int b_length = strlen(buffer); + if(b_length < 1) + return; + + char* b_value = g_strndup(buffer, b_length - 1); + int value = atoi(b_value); + + set_page(value - 1); + update_status(); + + g_free(b_value); } void bcmd_zoom(char* buffer, Argument* argument) { - + if(argument->n == ZOOM_IN) + Zathura.PDF.scale += ZOOM_STEP; + else if(argument->n == ZOOM_OUT) + Zathura.PDF.scale -= ZOOM_STEP; + else + Zathura.PDF.scale = 1.0; } /* special command implementation */