From e116ea99668266f41966bd62d0e4759e3bd3a4e7 Mon Sep 17 00:00:00 2001 From: Kalle Wallin Date: Fri, 3 Jun 2005 16:20:42 +0000 Subject: [PATCH] Added a "hide cursor" feature #0000417 git-svn-id: https://svn.musicpd.org/ncmpc/trunk@3307 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- ChangeLog | 3 +++ doc/config.sample | 3 +++ src/conf.c | 5 +++++ src/list_window.c | 11 ++++------- src/options.h | 1 + src/screen_play.c | 13 +++++++++++++ 6 files changed, 29 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4a2ac87..e6fb307 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2005-06-03: Kalle Wallin + * Added a "hide cursor" feature #0000417 + 2005-06-01: Kalle Wallin * main.c: Fixes #0000406, patch from René van Bevern * po/de.po: Updates from René van Bevern diff --git a/doc/config.sample b/doc/config.sample index 5d53e39..8dd3176 100644 --- a/doc/config.sample +++ b/doc/config.sample @@ -26,6 +26,9 @@ ## enable visible bell on alerts #visible-bell = no +## hide playlist cursor after x seconds (0 disables this feature) +#hide-cursor = 5 + ## change the xterm title #set-xterm-title = no diff --git a/src/conf.c b/src/conf.c index 11dba99..9222ed1 100644 --- a/src/conf.c +++ b/src/conf.c @@ -60,6 +60,7 @@ #define CONF_ENABLE_MOUSE "enable-mouse" #define CONF_CROSSFADE_TIME "crossfade-time" #define CONF_SEARCH_MODE "search-mode" +#define CONF_HIDE_CURSOR "hide-cursor" typedef enum { KEY_PARSER_UNKNOWN, @@ -477,6 +478,10 @@ read_rc_file(char *filename, options_t *options) { options->search_mode = atoi(value); } + else if( !strcasecmp(CONF_HIDE_CURSOR, name) ) + { + options->hide_cursor = atoi(value); + } else { match_found = 0; diff --git a/src/list_window.c b/src/list_window.c index c6f5375..7bbc6e1 100644 --- a/src/list_window.c +++ b/src/list_window.c @@ -165,12 +165,9 @@ list_window_paint(list_window_t *lw, { int i; int fill = options.wide_cursor; + int show_cursor = !(lw->flags & LW_HIDE_CURSOR); - if( lw->flags & LW_HIDE_CURSOR ) - { - lw->selected = -1; - } - else + if( show_cursor ) { while( lw->selected < lw->start ) { @@ -183,7 +180,7 @@ list_window_paint(list_window_t *lw, lw->clear=1; } } - + for(i=0; irows; i++) { int highlight = 0; @@ -203,7 +200,7 @@ list_window_paint(list_window_t *lw, else colors_use(lw->w, COLOR_LIST); - if( selected ) + if( show_cursor && selected ) wattron(lw->w, A_REVERSE); waddnstr(lw->w, label, lw->cols); diff --git a/src/options.h b/src/options.h index d264dd1..c3395bb 100644 --- a/src/options.h +++ b/src/options.h @@ -15,6 +15,7 @@ typedef struct int port; int crossfade_time; int search_mode; + int hide_cursor; gboolean reconnect; gboolean debug; gboolean find_wrap; diff --git a/src/screen_play.c b/src/screen_play.c index b86c876..51c722d 100644 --- a/src/screen_play.c +++ b/src/screen_play.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -341,6 +342,18 @@ play_paint(screen_t *screen, mpdclient_t *c) static void play_update(screen_t *screen, mpdclient_t *c) { + /* hide the cursor when mpd are playing and the user are inactive */ + if( options.hide_cursor>0 && c->status->state == MPD_STATUS_STATE_PLAY && + time(NULL)-screen->input_timestamp >= options.hide_cursor ) + { + lw->flags |= LW_HIDE_CURSOR; + } + else + { + lw->flags &= ~LW_HIDE_CURSOR; + } + + /* center the cursor */ if( options.auto_center ) { static int prev_song_id = 0; -- 2.30.2