Fix the page number once while parsing the synctex output

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
Sebastian Ramacher 2014-01-17 16:21:44 +01:00
parent 2778868599
commit bfb3acc1b1
2 changed files with 7 additions and 7 deletions

View File

@ -249,10 +249,10 @@ handle_method_call(GDBusConnection* UNUSED(connection),
g_variant_get(parameters, "(i)", &page);
bool ret = true;
if (page < 1 || (unsigned int)page > number_of_pages) {
if (page < 0 || (unsigned int)page >= number_of_pages) {
ret = false;
} else {
page_set(priv->zathura, page - 1);
page_set(priv->zathura, page);
}
GVariant* result = g_variant_new("(b)", ret);
@ -264,7 +264,7 @@ handle_method_call(GDBusConnection* UNUSED(connection),
g_variant_get(parameters, "(ia(dddd)a(idddd))", &page, &iter,
&secondary_iter);
if (page < 1 || (unsigned int)page > number_of_pages) {
if (page < 0 || (unsigned int)page >= number_of_pages) {
GVariant* result = g_variant_new("(b)", false);
g_variant_iter_free(iter);
g_variant_iter_free(secondary_iter);
@ -274,14 +274,14 @@ handle_method_call(GDBusConnection* UNUSED(connection),
/* get rectangles */
girara_list_t** rectangles = g_malloc0(number_of_pages * sizeof(girara_list_t*));
rectangles[page - 1] = girara_list_new2(g_free);
rectangles[page] = girara_list_new2(g_free);
zathura_rectangle_t temp_rect;
while (g_variant_iter_loop(iter, "(dddd)", &temp_rect.x1, &temp_rect.x2,
&temp_rect.y1, &temp_rect.y2)) {
zathura_rectangle_t* rect = g_malloc0(sizeof(zathura_rectangle_t));
*rect = temp_rect;
girara_list_append(rectangles[page - 1], rect);
girara_list_append(rectangles[page], rect);
}
g_variant_iter_free(iter);
@ -304,7 +304,7 @@ handle_method_call(GDBusConnection* UNUSED(connection),
}
g_variant_iter_free(secondary_iter);
highlight_rects(priv->zathura, page - 1, rectangles);
highlight_rects(priv->zathura, page, rectangles);
g_free(rectangles);
GVariant* result = g_variant_new("(b)", true);

View File

@ -168,7 +168,7 @@ synctex_rectangles_from_position(const char* filename, const char* position,
case SYNCTEX_PROP_PAGE:
if (g_scanner_get_next_token(scanner) == G_TOKEN_INT) {
current_page = g_scanner_cur_value(scanner).v_int;
current_page = g_scanner_cur_value(scanner).v_int - 1;
if (rpage == ZATHURA_PAGE_NUMBER_UNSPECIFIED) {
rpage = current_page;
}