X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=gui.c;h=42e7dd072ddbbad1ffdd04e8aeedab3884c51e53;hp=5ac1333b1c55ae969bfcf29d453ceed053a5ffc6;hb=b3c78fae27ed5313c06aea24fcd5d8ea13a21fab;hpb=481150224edabeee0a6bbfdab232df58e5c1224e diff --git a/gui.c b/gui.c index 5ac1333b..42e7dd07 100644 --- a/gui.c +++ b/gui.c @@ -109,6 +109,8 @@ static void com_scroll_up(void); static void com_scroll_down(void); static void com_page_up(void); static void com_page_down(void); +static void com_cancel_scrolling(void); +static void com_scroll_top(void); static struct gui_command command_list[] = { { @@ -186,6 +188,16 @@ static struct gui_command command_list[] = { .name = "page_down", .description = "scroll down one page", .handler = com_page_down + }, { + .key = "", + .name = "scroll_top", + .description = "scroll to top of buffer", + .handler = com_scroll_top + }, { + .key = "", + .name = "cancel_scroll", + .description = "deactivate scroll mode", + .handler = com_cancel_scrolling }, { .handler = NULL } @@ -230,6 +242,14 @@ static char *km_keyname(int c) sprintf(buf, ""); return buf; } + if (c == KEY_HOME) { + sprintf(buf, ""); + return buf; + } + if (c == KEY_END) { + sprintf(buf, ""); + return buf; + } if (c < 256 && c > -128 && iscntrl((unsigned char) c)) { if (c < 0) c += 256; @@ -1097,6 +1117,41 @@ static void print_scroll_msg(void) filled - scroll_position, ringbuffer_filled(bot_win_rb)); } +static void com_scroll_top(void) +{ + int i = RINGBUFFER_SIZE - 1; + unsigned lines = 0; + + while (i > 0 && !ringbuffer_get(bot_win_rb, i)) + i--; + /* i is oldest entry */ + for (; lines < bot.lines && i >= 0; i--) { + struct rb_entry *rbe = ringbuffer_get(bot_win_rb, i); + if (!rbe) + break; + lines += NUM_LINES(strlen(rbe->msg)); + } + i++; + if (lines > 0 && scroll_position != i) { + scroll_position = i; + redraw_bot_win(); + print_scroll_msg(); + return; + } + print_in_bar(COLOR_ERRMSG, "top of buffer is shown\n"); +} + +static void com_cancel_scrolling(void) +{ + + if (scroll_position == 0) { + print_in_bar(COLOR_ERRMSG, "bottom of buffer is shown\n"); + return; + } + scroll_position = 0; + redraw_bot_win(); +} + static void com_page_down(void) { unsigned lines = 0; @@ -1228,7 +1283,8 @@ static void com_reread_conf(void) .override = 1, .initialize = 1, .check_required = 0, - .check_ambiguity = 0 + .check_ambiguity = 0, + .print_errors = 0, }; if (!cf) { @@ -1236,8 +1292,11 @@ static void com_reread_conf(void) return; } PARA_INFO_LOG("rereading command line options and config file"); - gui_cmdline_parser(_argc, _argv, &conf); - gui_cmdline_parser_config_file(cf, &conf, ¶ms); + gui_cmdline_parser_ext(_argc, _argv, &conf, ¶ms); + if (gui_cmdline_parser_config_file(cf, &conf, ¶ms) != 0) { + PARA_EMERG_LOG("errors in config file"); + finish(EXIT_FAILURE); + } PARA_NOTICE_LOG("config file reloaded"); if (check_key_map_args() < 0) finish(EXIT_FAILURE); @@ -1394,7 +1453,8 @@ int main(int argc, char *argv[]) _argc = argc; _argv = argv; - gui_cmdline_parser(argc, argv, &conf); + if (gui_cmdline_parser(argc, argv, &conf) != 0) + exit(EXIT_FAILURE); HANDLE_VERSION_FLAG("gui", conf); cf = configfile_exists(); if (!cf && conf.config_file_given) { @@ -1407,9 +1467,11 @@ int main(int argc, char *argv[]) .override = 0, .initialize = 0, .check_required = 0, - .check_ambiguity = 0 + .check_ambiguity = 0, + .print_errors = 1, }; - gui_cmdline_parser_config_file(cf, &conf, ¶ms); + if (gui_cmdline_parser_config_file(cf, &conf, ¶ms) != 0) + exit(EXIT_FAILURE); } loglevel = get_loglevel_by_name(conf.loglevel_arg); if (check_key_map_args() < 0) {