mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 10:26:00 +01:00
Fixed reverse searching behaviour to be more like less/vi
Signed-off-by: Sebastian Ramacher <sebastian@ramacher.at>
This commit is contained in:
parent
8f50bf5ea0
commit
1a6b03fc62
4 changed files with 13 additions and 1 deletions
|
@ -340,6 +340,8 @@ cmd_search(girara_session_t* session, const char* input, girara_argument_t* argu
|
||||||
bool firsthit = true;
|
bool firsthit = true;
|
||||||
zathura_error_t error = ZATHURA_ERROR_OK;
|
zathura_error_t error = ZATHURA_ERROR_OK;
|
||||||
|
|
||||||
|
/* set search direction */
|
||||||
|
zathura->global.search_direction = argument->n;
|
||||||
|
|
||||||
unsigned int number_of_pages = zathura_document_get_number_of_pages(zathura->document);
|
unsigned int number_of_pages = zathura_document_get_number_of_pages(zathura->document);
|
||||||
unsigned int current_page_number = zathura_document_get_current_page_number(zathura->document);
|
unsigned int current_page_number = zathura_document_get_current_page_number(zathura->document);
|
||||||
|
@ -383,7 +385,12 @@ cmd_search(girara_session_t* session, const char* input, girara_argument_t* argu
|
||||||
if (page_id != 0) {
|
if (page_id != 0) {
|
||||||
page_set_delayed(zathura, zathura_page_get_index(page));
|
page_set_delayed(zathura, zathura_page_get_index(page));
|
||||||
}
|
}
|
||||||
g_object_set(page_widget, "search-current", 0, NULL);
|
if (argument->n == BACKWARD) {
|
||||||
|
/* start at bottom hit in page */
|
||||||
|
g_object_set(page_widget, "search-current", girara_list_size(result) - 1, NULL);
|
||||||
|
} else {
|
||||||
|
g_object_set(page_widget, "search-current", 0, NULL);
|
||||||
|
}
|
||||||
firsthit = false;
|
firsthit = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -743,7 +743,10 @@ sc_search(girara_session_t* session, girara_argument_t* argument,
|
||||||
|
|
||||||
const int num_pages = zathura_document_get_number_of_pages(zathura->document);
|
const int num_pages = zathura_document_get_number_of_pages(zathura->document);
|
||||||
const int cur_page = zathura_document_get_current_page_number(zathura->document);
|
const int cur_page = zathura_document_get_current_page_number(zathura->document);
|
||||||
|
|
||||||
int diff = argument->n == FORWARD ? 1 : -1;
|
int diff = argument->n == FORWARD ? 1 : -1;
|
||||||
|
if (zathura->global.search_direction == BACKWARD)
|
||||||
|
diff = -diff;
|
||||||
|
|
||||||
zathura_page_t* target_page = NULL;
|
zathura_page_t* target_page = NULL;
|
||||||
int target_idx = 0;
|
int target_idx = 0;
|
||||||
|
|
|
@ -62,6 +62,7 @@ zathura_create(void)
|
||||||
/* global settings */
|
/* global settings */
|
||||||
zathura->global.recolor = false;
|
zathura->global.recolor = false;
|
||||||
zathura->global.update_page_number = true;
|
zathura->global.update_page_number = true;
|
||||||
|
zathura->global.search_direction = FORWARD;
|
||||||
|
|
||||||
/* plugins */
|
/* plugins */
|
||||||
zathura->plugins.manager = zathura_plugin_manager_new();
|
zathura->plugins.manager = zathura_plugin_manager_new();
|
||||||
|
|
|
@ -97,6 +97,7 @@ struct zathura_s
|
||||||
bool recolor_keep_hue; /**< Keep hue when recoloring */
|
bool recolor_keep_hue; /**< Keep hue when recoloring */
|
||||||
bool recolor; /**< Recoloring mode switch */
|
bool recolor; /**< Recoloring mode switch */
|
||||||
bool update_page_number; /**< Update current page number */
|
bool update_page_number; /**< Update current page number */
|
||||||
|
int search_direction; /**< Current search direction (FORWARD or BACKWARD) */
|
||||||
girara_list_t* marks; /**< Marker */
|
girara_list_t* marks; /**< Marker */
|
||||||
char** arguments; /**> Arguments that were passed at startup */
|
char** arguments; /**> Arguments that were passed at startup */
|
||||||
} global;
|
} global;
|
||||||
|
|
Loading…
Reference in a new issue