aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKalle Wallin <kaw@linux.se>2005-06-03 16:20:42 +0000
committerKalle Wallin <kaw@linux.se>2005-06-03 16:20:42 +0000
commite116ea99668266f41966bd62d0e4759e3bd3a4e7 (patch)
treeb06ea42cb903fba36f264ade5536505c165b7108
parentd2ac8d20ee1a039df0df24a44d9f2ef901f69276 (diff)
downloadmpd-e116ea99668266f41966bd62d0e4759e3bd3a4e7.tar.gz
mpd-e116ea99668266f41966bd62d0e4759e3bd3a4e7.tar.xz
mpd-e116ea99668266f41966bd62d0e4759e3bd3a4e7.zip
Added a "hide cursor" feature #0000417
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@3307 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r--ChangeLog3
-rw-r--r--doc/config.sample3
-rw-r--r--src/conf.c5
-rw-r--r--src/list_window.c11
-rw-r--r--src/options.h1
-rw-r--r--src/screen_play.c13
6 files changed, 29 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 4a2ac87b1..e6fb3077d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2005-06-03: Kalle Wallin <kaw@linux.se>
+ * Added a "hide cursor" feature #0000417
+
2005-06-01: Kalle Wallin <kaw@linux.se>
* 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 5d53e39d2..8dd3176fe 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 11dba9993..9222ed18e 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 c6f5375a1..7bbc6e193 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; i<lw->rows; 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 d264dd1fa..c3395bbc4 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 b86c876de..51c722df5 100644
--- a/src/screen_play.c
+++ b/src/screen_play.c
@@ -21,6 +21,7 @@
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#include <glib.h>
#include <ncurses.h>
#include <panel.h>
@@ -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;