Merge branch 'sourcecmd' into 'develop'

Add source command

See merge request pwmt/zathura!47
This commit is contained in:
Sebastian Ramacher 2022-01-05 16:53:52 +00:00
commit 01ee79eeab
3 changed files with 32 additions and 0 deletions

View File

@ -19,6 +19,7 @@
#include "internal.h"
#include "render.h"
#include "adjustment.h"
#include "config.h"
#include <girara/session.h>
#include <girara/settings.h>
@ -605,3 +606,24 @@ cmd_version(girara_session_t* session, girara_list_t* UNUSED(argument_list))
return true;
}
bool
cmd_source(girara_session_t* session, girara_list_t* argument_list)
{
g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(session->global.data != NULL, false);
zathura_t* zathura = session->global.data;
const int argc = girara_list_size(argument_list);
if (argc > 1) {
girara_notify(session, GIRARA_ERROR, _("Too many arguments."));
return false;
} else if (argc == 1) {
zathura_set_config_dir(zathura, girara_list_nth(argument_list, 0));
config_load_files(zathura);
} else {
config_load_files(zathura);
}
return true;
}

View File

@ -169,4 +169,13 @@ bool cmd_offset(girara_session_t* session, girara_list_t* argument_list);
*/
bool cmd_version(girara_session_t* session, girara_list_t* argument_list);
/**
* Source config file
*
* @param session The used girara session
* @param argument_list List of passed arguments
* @return true if no error occurred
*/
bool cmd_source(girara_session_t* session, girara_list_t* argument_list);
#endif // COMMANDS_H

View File

@ -510,6 +510,7 @@ config_load_default(zathura_t* zathura)
girara_inputbar_command_add(gsession, "nohlsearch", "nohl", cmd_nohlsearch, NULL, _("Don't highlight current search results"));
girara_inputbar_command_add(gsession, "hlsearch", NULL, cmd_hlsearch, NULL, _("Highlight current search results"));
girara_inputbar_command_add(gsession, "version", NULL, cmd_version, NULL, _("Show version information"));
girara_inputbar_command_add(gsession, "source", NULL, cmd_source, NULL, _("Source config file"));
girara_special_command_add(gsession, '/', cmd_search, INCREMENTAL_SEARCH, FORWARD, NULL);
girara_special_command_add(gsession, '?', cmd_search, INCREMENTAL_SEARCH, BACKWARD, NULL);