zathura/synctex.c

41 lines
1.0 KiB
C
Raw Normal View History

/* See LICENSE file for license and copyright information */
#include "synctex.h"
#include "zathura.h"
#include "page.h"
#include "document.h"
#include <glib.h>
void
synctex_edit(zathura_t* zathura, zathura_page_t* page, int x, int y)
{
2012-09-17 17:23:58 +02:00
if (zathura == NULL || page == NULL) {
return;
}
2012-09-17 17:23:58 +02:00
zathura_document_t* document = zathura_page_get_document(page);
if (document == NULL) {
return;
2012-09-17 17:23:58 +02:00
}
const char *filename = zathura_document_get_path(document);
if (filename == NULL) {
return;
}
int page_idx = zathura_page_get_index(page);
char *buffer = g_strdup_printf("%d:%d:%d:%s", page_idx + 1, x, y, filename);
2012-09-17 17:23:58 +02:00
if (zathura->synctex.editor != NULL) {
char* argv[] = {"synctex", "edit", "-o", buffer, "-x", zathura->synctex.editor, NULL};
g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
} else {
char* argv[] = {"synctex", "edit", "-o", buffer, NULL};
g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
}
g_free(buffer);
}