diff --git a/config.c b/config.c index b074366..7735d76 100644 --- a/config.c +++ b/config.c @@ -221,8 +221,10 @@ config_load_default(zathura_t* zathura) girara_setting_add(gsession, "window-title-page", &bool_value, BOOLEAN, false, _("Display the page number in the window title"), NULL, NULL); bool_value = false; girara_setting_add(gsession, "statusbar-basename", &bool_value, BOOLEAN, false, _("Use basename of the file in the statusbar"), NULL, NULL); - bool_value = false; + bool_value = true; girara_setting_add(gsession, "synctex", &bool_value, BOOLEAN, false, _("Enable synctex support"), NULL, NULL); + string_value = ""; + girara_setting_add(gsession, "synctex-editor-command", string_value, STRING, false, _("Synctex editor command"), NULL, NULL); bool_value = true; girara_setting_add(gsession, "dbus-service", &bool_value, BOOLEAN, false, _("Enable D-Bus service"), NULL, NULL); string_value = "primary"; diff --git a/doc/man/_options.txt b/doc/man/_options.txt index edca4ea..f25c53b 100644 --- a/doc/man/_options.txt +++ b/doc/man/_options.txt @@ -23,11 +23,8 @@ -l, --debug=level Set log debug level (debug, info, warning, error) --s, --synctex - Enables synctex support - -x, --synctex-editor-command=command - Set the synctex editor command + Set the synctex editor command. Overrides the synctex-editor-command setting. --synctex-forward=input Jump to the given position. The switch expects the same format as specified for synctex's view -i. diff --git a/doc/man/zathurarc.5.rst b/doc/man/zathurarc.5.rst index 0216578..4277fd5 100644 --- a/doc/man/zathurarc.5.rst +++ b/doc/man/zathurarc.5.rst @@ -880,9 +880,23 @@ middle mouse button, or the Shift-Insert key combination. * Value type: String * Default value: primary +synctex +^^^^^^^ +En/Disables SyncTeX backward synchronization support. + +* Value type: Boolean +* Default value: true + +synctex-editor-command +^^^^^^^^^^^^^^^^^^^^^^ +Defines the command executed for SyncTeX backward synchronization. + +* Value type: String +* Default value: + syntex-dbus-service ^^^^^^^^^^^^^^^^^^^ -En/Disables the D-Bus service required for synctex forward synchronization. +En/Disables the D-Bus service required for SyncTeX forward synchronization. * Value type: Boolean * Default value: true diff --git a/main.c b/main.c index 4762371..c55d067 100644 --- a/main.c +++ b/main.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -48,7 +49,6 @@ main(int argc, char* argv[]) gchar* mode = NULL; bool forkback = false; bool print_version = false; - bool synctex = false; int page_number = ZATHURA_PAGE_NUMBER_UNSPECIFIED; int synctex_pid = -1; Window embed = 0; @@ -63,7 +63,6 @@ main(int argc, char* argv[]) { "page", 'P', 0, G_OPTION_ARG_INT, &page_number, _("Page number to go to"), "number" }, { "debug", 'l', 0, G_OPTION_ARG_STRING, &loglevel, _("Log level (debug, info, warning, error)"), "level" }, { "version", 'v', 0, G_OPTION_ARG_NONE, &print_version, _("Print version information"), NULL }, - { "synctex", 's', 0, G_OPTION_ARG_NONE, &synctex, _("Enable synctex support"), NULL }, { "synctex-editor-command", 'x', 0, G_OPTION_ARG_STRING, &synctex_editor, _("Synctex editor (forwarded to the synctex command)"), "cmd" }, { "synctex-forward", '\0', 0, G_OPTION_ARG_STRING, &synctex_fwd, _("Move to given synctex position"), "position" }, { "synctex-pid", '\0', 0, G_OPTION_ARG_INT, &synctex_pid, _("Highlight given position in the given process"), "pid" }, @@ -158,7 +157,6 @@ main(int argc, char* argv[]) zathura_set_config_dir(zathura, config_dir); zathura_set_data_dir(zathura, data_dir); zathura_set_plugin_dir(zathura, plugin_path); - zathura_set_synctex_editor_command(zathura, synctex_editor); zathura_set_argv(zathura, argv); /* Init zathura */ @@ -168,8 +166,9 @@ main(int argc, char* argv[]) return -1; } - /* Enable/Disable synctex support */ - zathura_set_synctex(zathura, synctex); + if (synctex_editor != NULL) { + girara_setting_set(zathura->ui.session, "synctex-editor-command", synctex_editor); + } /* Print version */ if (print_version == true) { diff --git a/page-widget.c b/page-widget.c index 36807d1..033a9de 100644 --- a/page-widget.c +++ b/page-widget.c @@ -721,10 +721,15 @@ cb_zathura_page_widget_button_release_event(GtkWidget* widget, GdkEventButton* b if (synctex == true && button->state & GDK_CONTROL_MASK) { /* synctex backwards sync */ - double scale = zathura_document_get_scale(document); - int x = button->x / scale, y = button->y / scale; + char* editor = NULL; + girara_setting_get(priv->zathura->ui.session, "synctex-editor-command", &editor); + if (editor != NULL && *editor != '\0') { + double scale = zathura_document_get_scale(document); + int x = button->x / scale, y = button->y / scale; - synctex_edit(priv->zathura, priv->page, x, y); + synctex_edit(editor, priv->page, x, y); + } + g_free(editor); } else { zathura_rectangle_t tmp = priv->mouse.selection; diff --git a/synctex.c b/synctex.c index c71c4b6..bbe9c2d 100644 --- a/synctex.c +++ b/synctex.c @@ -2,18 +2,18 @@ #include #include +#include #include "synctex.h" #include "zathura.h" #include "page.h" #include "document.h" #include "utils.h" -#include "synctex/synctex_parser.h" void -synctex_edit(zathura_t* zathura, zathura_page_t* page, int x, int y) +synctex_edit(const char* editor, zathura_page_t* page, int x, int y) { - if (zathura == NULL || page == NULL || zathura->synctex.editor == NULL) { + if (editor == NULL || page == NULL) { return; } @@ -53,7 +53,7 @@ synctex_edit(zathura_t* zathura, zathura_page_t* page, int x, int y) gchar** argv = NULL; gint argc = 0; - if (g_shell_parse_argv(zathura->synctex.editor, &argc, &argv, NULL) == TRUE) { + if (g_shell_parse_argv(editor, &argc, &argv, NULL) == TRUE) { for (gint i = 0; i != argc; ++i) { char* temp = girara_replace_substring(argv[i], "%{line}", linestr); g_free(argv[i]); diff --git a/synctex.h b/synctex.h index 427994c..50ce3c6 100644 --- a/synctex.h +++ b/synctex.h @@ -10,7 +10,7 @@ typedef struct synctex_page_rect_s { zathura_rectangle_t rect; } synctex_page_rect_t; -void synctex_edit(zathura_t* zathura, zathura_page_t* page, int x, int y); +void synctex_edit(const char* editor, zathura_page_t* page, int x, int y); girara_list_t* synctex_rectangles_from_position(const char* filename, const char* input_file, int line, int column, unsigned int* page, girara_list_t** secondary_rects); diff --git a/zathura.c b/zathura.c index f5ccfb3..0404b88 100644 --- a/zathura.c +++ b/zathura.c @@ -421,31 +421,6 @@ zathura_set_plugin_dir(zathura_t* zathura, const char* dir) } -void -zathura_set_synctex_editor_command(zathura_t* zathura, const char* command) -{ - g_return_if_fail(zathura != NULL); - - if (zathura->synctex.editor != NULL) { - g_free(zathura->synctex.editor); - } - - if (command != NULL) { - zathura->synctex.editor = g_strdup(command); - } else { - zathura->synctex.editor = NULL; - } -} - -void -zathura_set_synctex(zathura_t* zathura, bool value) -{ - g_return_if_fail(zathura != NULL); - g_return_if_fail(zathura->ui.session != NULL); - - girara_setting_set(zathura->ui.session, "synctex", &value); -} - void zathura_set_argv(zathura_t* zathura, char** argv) { diff --git a/zathura.h b/zathura.h index d2afb72..fda81ae 100644 --- a/zathura.h +++ b/zathura.h @@ -129,12 +129,6 @@ struct zathura_s gchar* data_dir; /**< Path to the data directory */ } config; - struct - { - bool enabled; - gchar* editor; - } synctex; - struct { GtkPrintSettings* settings; /**< Print settings */ @@ -263,22 +257,6 @@ void zathura_set_data_dir(zathura_t* zathura, const char* dir); */ void zathura_set_plugin_dir(zathura_t* zathura, const char* dir); -/** - * Enables synctex support and sets the synctex editor command - * - * @param zathura The zathura session - * @param command Synctex editor command - */ -void zathura_set_synctex_editor_command(zathura_t* zathura, const char* command); - -/** - * En/Disable zathuras synctex support - * - * @param zathura The zathura session - * @param value The value - */ -void zathura_set_synctex(zathura_t* zathura, bool value); - /** * Sets the program parameters *