From: Kalle Wallin Date: Sat, 27 Mar 2004 16:21:19 +0000 (+0000) Subject: Added function screen_getch(). X-Git-Tag: v0.12_alpha1~645 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d34028b356f2d4d29e5e5f40229117d6bad8e618;p=ncmpc.git Added function screen_getch(). git-svn-id: https://svn.musicpd.org/ncmpc/trunk@509 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- diff --git a/screen_utils.c b/screen_utils.c index 9feda74..5788b34 100644 --- a/screen_utils.c +++ b/screen_utils.c @@ -15,8 +15,33 @@ #define FIND_PROMPT "Find: " #define RFIND_PROMPT "Find backward: " +int +screen_getch(WINDOW *w, char *prompt) +{ + int key = -1; + int prompt_len = strlen(prompt); + + wclear(w); + wmove(w, 0, 0); + waddstr(w, prompt); + wmove(w, 0, prompt_len); + + echo(); + curs_set(1); + timeout(-1); + + key = wgetch(w); + + noecho(); + curs_set(0); + timeout(SCREEN_TIMEOUT); + + return key; +} + + char * -screen_readln(WINDOW *w, char *prompt) +screen_getstr(WINDOW *w, char *prompt) { char buf[256], *line = NULL; int prompt_len = strlen(prompt); @@ -71,7 +96,7 @@ screen_find(screen_t *screen, case CMD_LIST_FIND_NEXT: case CMD_LIST_RFIND_NEXT: if( !screen->findbuf ) - screen->findbuf=screen_readln(screen->status_window.w, prompt); + screen->findbuf=screen_getstr(screen->status_window.w, prompt); if( reversed ) retval = list_window_rfind(lw, callback_fn, diff --git a/screen_utils.h b/screen_utils.h index 87cb6e0..30c58bf 100644 --- a/screen_utils.h +++ b/screen_utils.h @@ -1,6 +1,9 @@ +/* read a characher from the status window */ +int screen_getch(WINDOW *w, char *prompt); + /* read a string from the status window */ -char *screen_readln(WINDOW *w, char *prompt); +char *screen_getstr(WINDOW *w, char *prompt); /* query user for a string and find it in a list window */ int screen_find(screen_t *screen,