mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-10 22:13:48 +01:00
Bookmark command line argument
This commit is contained in:
parent
22580f24bf
commit
eb1fe0a64d
@ -253,7 +253,7 @@ cmd_open(girara_session_t* session, girara_list_t* argument_list)
|
|||||||
|
|
||||||
document_open_idle(zathura, girara_list_nth(argument_list, 0),
|
document_open_idle(zathura, girara_list_nth(argument_list, 0),
|
||||||
(argc == 2) ? girara_list_nth(argument_list, 1) : NULL,
|
(argc == 2) ? girara_list_nth(argument_list, 1) : NULL,
|
||||||
ZATHURA_PAGE_NUMBER_UNSPECIFIED, NULL, NULL, NULL);
|
ZATHURA_PAGE_NUMBER_UNSPECIFIED, NULL, NULL, NULL, NULL);
|
||||||
} else {
|
} else {
|
||||||
girara_notify(session, GIRARA_ERROR, _("No arguments given."));
|
girara_notify(session, GIRARA_ERROR, _("No arguments given."));
|
||||||
return false;
|
return false;
|
||||||
|
@ -222,7 +222,7 @@ handle_open_document(zathura_t* zathura, GVariant* parameters,
|
|||||||
document_open_idle(zathura, filename,
|
document_open_idle(zathura, filename,
|
||||||
strlen(password) > 0 ? password : NULL,
|
strlen(password) > 0 ? password : NULL,
|
||||||
page,
|
page,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL, NULL);
|
||||||
g_free(filename);
|
g_free(filename);
|
||||||
g_free(password);
|
g_free(password);
|
||||||
|
|
||||||
|
@ -135,6 +135,7 @@ main(int argc, char* argv[])
|
|||||||
gchar* synctex_editor = NULL;
|
gchar* synctex_editor = NULL;
|
||||||
gchar* synctex_fwd = NULL;
|
gchar* synctex_fwd = NULL;
|
||||||
gchar* mode = NULL;
|
gchar* mode = NULL;
|
||||||
|
gchar* bookmark_name = NULL;
|
||||||
gchar* search_string = NULL;
|
gchar* search_string = NULL;
|
||||||
bool forkback = false;
|
bool forkback = false;
|
||||||
bool print_version = false;
|
bool print_version = false;
|
||||||
@ -157,6 +158,7 @@ main(int argc, char* argv[])
|
|||||||
{ "synctex-forward", '\0', 0, G_OPTION_ARG_STRING, &synctex_fwd, _("Move to given synctex position"), "position" },
|
{ "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" },
|
{ "synctex-pid", '\0', 0, G_OPTION_ARG_INT, &synctex_pid, _("Highlight given position in the given process"), "pid" },
|
||||||
{ "mode", '\0', 0, G_OPTION_ARG_STRING, &mode, _("Start in a non-default mode"), "mode" },
|
{ "mode", '\0', 0, G_OPTION_ARG_STRING, &mode, _("Start in a non-default mode"), "mode" },
|
||||||
|
{ "bookmark", 'b', 0, G_OPTION_ARG_STRING, &bookmark_name, _("Bookmark to go to"), "bookmark" },
|
||||||
{ "find", 'f', 0, G_OPTION_ARG_STRING, &search_string, _("Search for the given phrase and display results"), "string" },
|
{ "find", 'f', 0, G_OPTION_ARG_STRING, &search_string, _("Search for the given phrase and display results"), "string" },
|
||||||
{ NULL, '\0', 0, 0, NULL, NULL, NULL }
|
{ NULL, '\0', 0, 0, NULL, NULL, NULL }
|
||||||
};
|
};
|
||||||
@ -298,8 +300,13 @@ main(int argc, char* argv[])
|
|||||||
if (page_number > 0) {
|
if (page_number > 0) {
|
||||||
--page_number;
|
--page_number;
|
||||||
}
|
}
|
||||||
document_open_idle(zathura, argv[file_idx], password, page_number, mode,
|
document_open_idle(zathura, argv[file_idx], password, page_number,
|
||||||
synctex_fwd, search_string);
|
mode, synctex_fwd, bookmark_name, search_string);
|
||||||
|
} else if (bookmark_name != NULL) {
|
||||||
|
girara_error("Can not use bookmark argument when no file is given");
|
||||||
|
ret = -1;
|
||||||
|
zathura_free(zathura);
|
||||||
|
goto free_and_ret;
|
||||||
} else if (search_string != NULL) {
|
} else if (search_string != NULL) {
|
||||||
girara_error("Can not use find argument when no file is given");
|
girara_error("Can not use find argument when no file is given");
|
||||||
ret = -1;
|
ret = -1;
|
||||||
@ -323,6 +330,7 @@ free_and_ret:
|
|||||||
g_free(synctex_editor);
|
g_free(synctex_editor);
|
||||||
g_free(synctex_fwd);
|
g_free(synctex_fwd);
|
||||||
g_free(mode);
|
g_free(mode);
|
||||||
|
g_free(bookmark_name);
|
||||||
g_free(search_string);
|
g_free(search_string);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -57,6 +57,7 @@ typedef struct zathura_document_info_s {
|
|||||||
int page_number;
|
int page_number;
|
||||||
char* mode;
|
char* mode;
|
||||||
char* synctex;
|
char* synctex;
|
||||||
|
char* bookmark_name;
|
||||||
char* search_string;
|
char* search_string;
|
||||||
} zathura_document_info_t;
|
} zathura_document_info_t;
|
||||||
|
|
||||||
@ -78,6 +79,7 @@ free_document_info(zathura_document_info_t* document_info)
|
|||||||
g_free(document_info->password);
|
g_free(document_info->password);
|
||||||
g_free(document_info->mode);
|
g_free(document_info->mode);
|
||||||
g_free(document_info->synctex);
|
g_free(document_info->synctex);
|
||||||
|
g_free(document_info->bookmark_name);
|
||||||
g_free(document_info->search_string);
|
g_free(document_info->search_string);
|
||||||
g_free(document_info);
|
g_free(document_info);
|
||||||
}
|
}
|
||||||
@ -883,6 +885,13 @@ document_info_open(gpointer data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (document_info->bookmark_name != NULL) {
|
||||||
|
girara_list_t* arg_list = girara_list_new();
|
||||||
|
girara_list_append(arg_list, document_info->bookmark_name);
|
||||||
|
cmd_bookmark_open(document_info->zathura->ui.session, arg_list);
|
||||||
|
girara_list_free(arg_list);
|
||||||
|
}
|
||||||
|
|
||||||
if (document_info->search_string != NULL) {
|
if (document_info->search_string != NULL) {
|
||||||
girara_argument_t search_arg;
|
girara_argument_t search_arg;
|
||||||
search_arg.n = 1; // Forward search
|
search_arg.n = 1; // Forward search
|
||||||
@ -1309,7 +1318,7 @@ document_open_synctex(zathura_t* zathura, const char* path, const char* uri,
|
|||||||
void
|
void
|
||||||
document_open_idle(zathura_t* zathura, const char* path, const char* password,
|
document_open_idle(zathura_t* zathura, const char* path, const char* password,
|
||||||
int page_number, const char* mode, const char* synctex,
|
int page_number, const char* mode, const char* synctex,
|
||||||
const char *search_string)
|
const char* bookmark_name, const char *search_string)
|
||||||
{
|
{
|
||||||
g_return_if_fail(zathura != NULL);
|
g_return_if_fail(zathura != NULL);
|
||||||
g_return_if_fail(path != NULL);
|
g_return_if_fail(path != NULL);
|
||||||
@ -1331,6 +1340,9 @@ document_open_idle(zathura_t* zathura, const char* path, const char* password,
|
|||||||
if (synctex != NULL) {
|
if (synctex != NULL) {
|
||||||
document_info->synctex = g_strdup(synctex);
|
document_info->synctex = g_strdup(synctex);
|
||||||
}
|
}
|
||||||
|
if (bookmark_name != NULL) {
|
||||||
|
document_info->bookmark_name = g_strdup(bookmark_name);
|
||||||
|
}
|
||||||
if (search_string != NULL) {
|
if (search_string != NULL) {
|
||||||
document_info->search_string = g_strdup(search_string);
|
document_info->search_string = g_strdup(search_string);
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ bool document_open_synctex(zathura_t* zathura, const char* path, const char* uri
|
|||||||
void document_open_idle(zathura_t* zathura, const char* path,
|
void document_open_idle(zathura_t* zathura, const char* path,
|
||||||
const char* password, int page_number,
|
const char* password, int page_number,
|
||||||
const char* mode, const char* synctex,
|
const char* mode, const char* synctex,
|
||||||
const char* search_string);
|
const char* bookmark_name, const char *search_string);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save a open file
|
* Save a open file
|
||||||
|
Loading…
Reference in New Issue
Block a user