Commit eabd883e authored by Sebastian Ramacher's avatar Sebastian Ramacher

Add synctex-editor-command setting

Also, turn on SyncTeX backward synchronization per default and remove -s option.
Signed-off-by: Sebastian Ramacher's avatarSebastian Ramacher <sebastian+dev@ramacher.at>
parent 0db37027
......@@ -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";
......
......@@ -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.
......
......@@ -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
......
......@@ -5,6 +5,7 @@
#include <errno.h>
#include <girara/utils.h>
#include <girara/settings.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
#include <limits.h>
......@@ -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) {
......
......@@ -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;
......
......@@ -2,18 +2,18 @@
#include <glib.h>
#include <girara/utils.h>
#include <synctex/synctex_parser.h>
#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]);
......
......@@ -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);
......
......@@ -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)
{
......
......@@ -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
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment