mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 12:15:59 +01:00
Check for numeric events
This commit is contained in:
parent
e4c145a67e
commit
800d039293
4 changed files with 39 additions and 3 deletions
25
callbacks.c
25
callbacks.c
|
@ -335,3 +335,28 @@ cb_setting_recolor_change(girara_session_t* session, const char* name,
|
|||
render_all(zathura);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
cb_unknown_command(girara_session_t* session, const char* input)
|
||||
{
|
||||
g_return_val_if_fail(session != NULL, false);
|
||||
g_return_val_if_fail(session->global.data != NULL, false);
|
||||
g_return_val_if_fail(input != NULL, false);
|
||||
|
||||
zathura_t* zathura = session->global.data;
|
||||
|
||||
if (zathura->document == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* check for number */
|
||||
for (unsigned int i = 0; i < strlen(input); i++) {
|
||||
if (g_ascii_isdigit(input[i]) == FALSE) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
page_set(zathura, atoi(input) - 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
10
callbacks.h
10
callbacks.h
|
@ -111,4 +111,14 @@ bool cb_view_resized(GtkWidget* widget, GtkAllocation* allocation, zathura_t* za
|
|||
void cb_setting_recolor_change(girara_session_t* session, const char* name,
|
||||
girara_setting_type_t type, void* value, void* data);
|
||||
|
||||
/**
|
||||
* Unknown command handler which is used to handle the strict numeric goto
|
||||
* command
|
||||
*
|
||||
* @param session The girara session
|
||||
* @param input The command input
|
||||
* @return true if the input has been handled
|
||||
*/
|
||||
bool cb_unknown_command(girara_session_t* session, const char* input);
|
||||
|
||||
#endif // CALLBACKS_H
|
||||
|
|
|
@ -338,7 +338,7 @@ cc_export(girara_session_t* session, const char* input)
|
|||
girara_list_t* images = zathura_page_images_get(page, NULL);
|
||||
if (images != NULL) {
|
||||
unsigned int image_number = 1;
|
||||
GIRARA_LIST_FOREACH(images, zathura_image_t*, iter, image)
|
||||
GIRARA_LIST_FOREACH(images, zathura_image_t*, iter, UNUSED(image))
|
||||
char* image_string = g_strdup_printf("image-p%d-%d", page_id + 1, image_number);
|
||||
girara_completion_group_add_element(image_group, image_string, NULL);
|
||||
g_free(image_string);
|
||||
|
|
|
@ -207,6 +207,7 @@ zathura_init(int argc, char* argv[])
|
|||
|
||||
/* girara events */
|
||||
zathura->ui.session->events.buffer_changed = cb_buffer_changed;
|
||||
zathura->ui.session->events.unknown_command = cb_unknown_command;
|
||||
|
||||
/* page view */
|
||||
zathura->ui.page_widget = gtk_table_new(0, 0, TRUE);
|
||||
|
|
Loading…
Reference in a new issue