X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=gui.c;h=baab0bd905e56fee0a7a821e0c536e15b532db5f;hp=e157dd1ac184d18958e19f1c95b5f937cccd9f08;hb=e2eebf654cae2fc004cee516a0e165127c0214ca;hpb=625fdbbafaf3842753bff02b349eaaf9554d846d diff --git a/gui.c b/gui.c index e157dd1a..baab0bd9 100644 --- a/gui.c +++ b/gui.c @@ -23,6 +23,7 @@ #include "list.h" #include "sched.h" #include "signal.h" +#include "ggo.h" #include "version.h" /** define the array of error lists needed by para_gui */ @@ -293,7 +294,7 @@ static char *configfile_exists(void) static void add_spaces(WINDOW* win, unsigned int num) { char space[] = " "; - unsigned sz = sizeof(space); + unsigned sz = sizeof(space) - 1; /* number of spaces */ while (num >= sz) { waddstr(win, space); @@ -604,8 +605,8 @@ static void print_welcome(void) { if (loglevel > LL_NOTICE) return; - outputf(COLOR_WELCOME, "Welcome to para_gui " PACKAGE_VERSION - " \"" CODENAME "\". Theme: %s", theme.name); + outputf(COLOR_WELCOME, "Welcome to %s. Theme: %s", + version_single_line("gui"), theme.name); wclrtoeol(bot.win); } @@ -1431,8 +1432,7 @@ static void com_enlarge_top_win(void) static void com_version(void) { - print_in_bar(COLOR_MSG, "para_gui " PACKAGE_VERSION " \"" - CODENAME "\""); + print_in_bar(COLOR_MSG, "%s", version_single_line("gui")); } __noreturn static void com_quit(void) @@ -1511,6 +1511,15 @@ static void handle_command(int c) km_keyname(c)); } +__noreturn static void print_help_and_die(void) +{ + struct ggo_help h = DEFINE_GGO_HELP(gui); + bool d = conf.detailed_help_given; + + ggo_print_help(&h, d? GPH_STANDARD_FLAGS_DETAILED : GPH_STANDARD_FLAGS); + exit(0); +} + int main(int argc, char *argv[]) { int ret; @@ -1520,7 +1529,10 @@ int main(int argc, char *argv[]) _argv = argv; gui_cmdline_parser(argc, argv, &conf); /* exits on errors */ - HANDLE_VERSION_FLAG("gui", conf); + loglevel = get_loglevel_by_name(conf.loglevel_arg); + version_handle_flag("gui", conf.version_given); + if (conf.help_given || conf.detailed_help_given) + print_help_and_die(); cf = configfile_exists(); if (!cf && conf.config_file_given) { fprintf(stderr, "can not read config file %s\n", @@ -1536,8 +1548,8 @@ int main(int argc, char *argv[]) .print_errors = 1, }; gui_cmdline_parser_config_file(cf, &conf, ¶ms); + loglevel = get_loglevel_by_name(conf.loglevel_arg); } - loglevel = get_loglevel_by_name(conf.loglevel_arg); if (check_key_map_args() < 0) { fprintf(stderr, "invalid key map\n"); exit(EXIT_FAILURE);