Commit d3203905 authored by Moritz Lipp's avatar Moritz Lipp

Implement :version command

parent 5ad33504
......@@ -15,6 +15,7 @@
#include "utils.h"
#include "page-widget.h"
#include "page.h"
#include "plugin.h"
#include "internal.h"
#include "render.h"
......@@ -518,3 +519,43 @@ cmd_offset(girara_session_t* session, girara_list_t* argument_list)
return true;
}
bool
cmd_version(girara_session_t* session, girara_list_t* UNUSED(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;
GString* string = g_string_new(NULL);
/* zathura version */
char* zathura_version = g_strdup_printf("zathura %d.%d.%d", ZATHURA_VERSION_MAJOR, ZATHURA_VERSION_MINOR, ZATHURA_VERSION_REV);
g_string_append(string, zathura_version);
g_free(zathura_version);
/* plugin information */
girara_list_t* plugins = zathura_plugin_manager_get_plugins(zathura->plugins.manager);
if (plugins != NULL) {
GIRARA_LIST_FOREACH(plugins, zathura_plugin_t*, iter, plugin)
char* name = zathura_plugin_get_name(plugin);
zathura_plugin_version_t version = zathura_plugin_get_version(plugin);
char* text = g_strdup_printf("\n<i>(plugin)</i> %s (%d.%d.%d) <i>(%s)</i>",
(name == NULL) ? "-" : name,
version.major,
version.minor,
version.rev,
zathura_plugin_get_path(plugin)
);
g_string_append(string, text);
g_free(text);
GIRARA_LIST_FOREACH_END(plugins, zathura_plugin_t*, iter, plugin);
}
/* display information */
girara_notify(session, GIRARA_INFO, "%s", string->str);
g_string_free(string, TRUE);
return true;
}
......@@ -151,4 +151,13 @@ bool cmd_export(girara_session_t* session, girara_list_t* argument_list);
*/
bool cmd_offset(girara_session_t* session, girara_list_t* argument_list);
/**
* Shows version information
*
* @param session The used girara session
* @param argument_list List of passed arguments
* @return true if no error occured
*/
bool cmd_version(girara_session_t* session, girara_list_t* argument_list);
#endif // COMMANDS_H
......@@ -282,6 +282,7 @@ config_load_default(zathura_t* zathura)
girara_inputbar_command_add(gsession, "delmarks", "delm", cmd_marks_delete, NULL, _("Delete the specified marks"));
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_special_command_add(gsession, '/', cmd_search, true, FORWARD, NULL);
girara_special_command_add(gsession, '?', cmd_search, true, BACKWARD, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment