X-Git-Url: https://git.deb.at/?a=blobdiff_plain;f=ui.c;h=901322b50712c6f4295d71e11336d1713845c096;hb=fb60820672fa03a647439be4aeaecf78ac2cd6f4;hp=45aa61e14f5c1ec124b3e6033e41cf2fcd7e3bb9;hpb=e92078b6d282cb7440124eee19dc42a1201baf90;p=pkg%2Fabook.git diff --git a/ui.c b/ui.c index 45aa61e..901322b 100644 --- a/ui.c +++ b/ui.c @@ -232,7 +232,7 @@ statusline_addstr(const char *str) } char * -ui_readline(char *prompt, char *s, int limit, bool use_completion) +ui_readline(char *prompt, char *s, size_t limit, bool use_completion) { int y, x; char *ret; @@ -241,10 +241,13 @@ ui_readline(char *prompt, char *s, int limit, bool use_completion) getyx(bottom, y, x); - ret = abook_readline(bottom, y, x, s, limit, use_completion); + ret = abook_readline(bottom, y, x, s, use_completion); - if(ret) + if(ret) { strtrim(ret); + if(strlen(ret) > limit && limit > 0) + ret[limit] = '\0'; + } return ret; } @@ -253,23 +256,21 @@ int statusline_ask_boolean(char *msg, int def) { int ret; - char *msg2 = strconcat(msg, def ? " (Y/n)?" : " (y/N)?", NULL); + char *msg2 = strconcat(msg, def ? _(" (Y/n)?") : _(" (y/N)?"), NULL); + char ch; statusline_addstr(msg2); free(msg2); - switch(tolower(getch())) { - case 'n': - ret = FALSE; - break; - case 'y': - ret = TRUE; - break; - default: - ret = def; - break; - } + ch = tolower(getch()); + + if(ch == *(S_("keybinding for no|n"))) + ret = FALSE; + else if(ch == *(S_("keybinding for yes|y"))) + ret = TRUE; + else + ret = def; clear_statusline(); @@ -450,7 +451,7 @@ get_commands() case 'p': ui_print_database(); break; - case 'u': launch_wwwbrowser(list_current_item()); + case 'v': launch_wwwbrowser(list_current_item()); refresh_screen(); break; } @@ -595,7 +596,7 @@ ui_open_datafile() load_database(filename); if(items == 0) { - statusline_msg(_("Sorry, that specified file appears not to be a valid abook addressbook")); + statusline_msg(_("Sorry, the specified file appears not to be a valid abook addressbook")); load_database(datafile); } else { free(datafile);