Merge branch 'develop' of pwmt.org:zathura into develop

This commit is contained in:
Moritz Lipp 2011-09-29 17:09:12 +02:00
commit 3d0abd5292
3 changed files with 44 additions and 10 deletions

View file

@ -6,6 +6,7 @@
#include <unistd.h>
#include <libgen.h>
#include "bookmarks.h"
#include "completion.h"
#include "utils.h"
@ -142,3 +143,26 @@ error_free:
return NULL;
}
girara_completion_t*
cc_bookmarks(girara_session_t* session, char* input)
{
g_return_val_if_fail(session != NULL, NULL);
g_return_val_if_fail(session->global.data != NULL, NULL);
zathura_t* zathura = session->global.data;
girara_completion_t* completion = girara_completion_init();
girara_completion_group_t* group = girara_completion_group_create(session, NULL);
const size_t input_length = input ? strlen(input) : 0;
GIRARA_LIST_FOREACH(zathura->bookmarks.bookmarks, zathura_bookmark_t*, iter, bookmark)
if (input_length <= strlen(bookmark->id) && !strncmp(input, bookmark->id, input_length)) {
gchar* paged = g_strdup_printf("Page %d", bookmark->page);
girara_completion_group_add_element(group, bookmark->id, paged);
g_free(paged);
}
GIRARA_LIST_FOREACH_END(zathura->bookmarks.bookmarks, zathura_bookmark_t*, iter, bookmark)
return completion;
}

View file

@ -15,4 +15,14 @@
*/
girara_completion_t* cc_open(girara_session_t* session, char* input);
/**
* Completion for the bmarks command - Creates a list of bookmarks
*
* @param session The used girara session
* @param input The current input
* @return The completion object or NULL if an error occured
*/
girara_completion_t* cc_bookmarks(girara_session_t* session, char* input);
#endif // COMPLETION_H

View file

@ -108,8 +108,8 @@ config_load_default(zathura_t* zathura)
/* define default inputbar commands */
girara_inputbar_command_add(gsession, "bmark", NULL, cmd_bookmark_create, NULL, "Add a bookmark");
girara_inputbar_command_add(gsession, "bdelete", NULL, cmd_bookmark_delete, NULL, "Delete a bookmark");
girara_inputbar_command_add(gsession, "blist", NULL, cmd_bookmark_open, NULL, "List all bookmarks");
girara_inputbar_command_add(gsession, "bdelete", NULL, cmd_bookmark_delete, cc_bookmarks, "Delete a bookmark");
girara_inputbar_command_add(gsession, "blist", NULL, cmd_bookmark_open, cc_bookmarks, "List all bookmarks");
girara_inputbar_command_add(gsession, "close", NULL, cmd_close, NULL, "Close current file");
girara_inputbar_command_add(gsession, "info", NULL, cmd_info, NULL, "Show file information");
girara_inputbar_command_add(gsession, "help", NULL, cmd_help, NULL, "Show help");