X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fscreen_utils.c;h=baa371be1aec79ae12c1ece3bd4691b1cb995869;hb=9a500d13055f16b70796a5fce5ec6de4a2844187;hp=6473244bbce7534dcbe4281ca51ee381e3e7d333;hpb=39758c8503fb5390afaceeff3dd5b0bca75feb97;p=ncmpc.git diff --git a/src/screen_utils.c b/src/screen_utils.c index 6473244..baa371b 100644 --- a/src/screen_utils.c +++ b/src/screen_utils.c @@ -38,6 +38,15 @@ #define FIND_PROMPT _("Find: ") #define RFIND_PROMPT _("Find backward: ") +void +screen_bell(void) +{ + if( options.audible_bell ) + beep(); + if( options.visible_bell ) + flash(); +} + int screen_getch(WINDOW *w, char *prompt) { @@ -54,11 +63,14 @@ screen_getch(WINDOW *w, char *prompt) curs_set(1); timeout(-1); - while( (key=wgetch(w)) == ERR ) + while( (key=my_wgetch(w)) == ERR ) ; - - if( key==KEY_RESIZE ) - screen_resize(); + +#ifdef HAVE_GETMOUSE + /* ignore mouse events */ + if( key==KEY_MOUSE ) + return screen_getch(w, prompt); +#endif noecho(); curs_set(0); @@ -78,6 +90,7 @@ screen_readln(WINDOW *w, wmove(w, 0,0); curs_set(1); + colors_use(w, COLOR_STATUS_ALERT); line = wreadln(w, prompt, value, COLS, history, gcmp); curs_set(0); return line; @@ -149,7 +162,7 @@ screen_find(screen_t *screen, else { screen_status_printf(_("Unable to find \'%s\'"), screen->findbuf); - beep(); + screen_bell(); } return 1; default: @@ -158,4 +171,68 @@ screen_find(screen_t *screen, return 0; } +void +screen_display_completion_list(screen_t *screen, GList *list) +{ + static GList *prev_list = NULL; + static gint prev_length = 0; + static gint offset = 0; + WINDOW *w = screen->main_window.w; + gint length, y=0; + + length = g_list_length(list); + if( list==prev_list && length==prev_length ) + { + offset += screen->main_window.rows; + if( offset>=length ) + offset=0; + } + else + { + prev_list = list; + prev_length = length; + offset = 0; + } + + colors_use(w, COLOR_STATUS_ALERT); + while( ymain_window.rows ) + { + GList *item = g_list_nth(list, y+offset); + wmove(w, y++, 0); + wclrtoeol(w); + if( item ) + { + gchar *tmp = g_strdup(item->data); + waddstr(w, basename(tmp)); + g_free(tmp); + } + } + wrefresh(w); + doupdate(); + colors_use(w, COLOR_LIST); +} + +void +set_xterm_title(char *format, ...) +{ + /* the current xterm title exists under the WM_NAME property */ + /* and can be retreived with xprop -id $WINDOWID */ + + if( options.enable_xterm_title ) + { + if( g_getenv("WINDOWID") ) + { + char *msg; + va_list ap; + + va_start(ap,format); + msg = g_strdup_vprintf(format,ap); + va_end(ap); + printf("%c]0;%s%c", '\033', msg, '\007'); + g_free(msg); + } + else + options.enable_xterm_title = FALSE; + } +}