summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: abf8689)
raw | patch | inline | side by side (parent: abf8689)
author | Kalle Wallin <kaw@linux.se> | |
Mon, 5 Apr 2004 08:56:50 +0000 (08:56 +0000) | ||
committer | Kalle Wallin <kaw@linux.se> | |
Mon, 5 Apr 2004 08:56:50 +0000 (08:56 +0000) |
command.c | patch | blob | history | |
command.h | patch | blob | history | |
conf.c | patch | blob | history | |
doc/ncmpcrc.sample | patch | blob | history | |
screen.c | patch | blob | history | |
screen_help.c | patch | blob | history | |
screen_play.c | patch | blob | history |
diff --git a/command.c b/command.c
index e165aa466b9c09297a104ea91a09231a24ecf2c0..f3e129f043a9a0b1b289475c7276fbcdae6d1384 100644 (file)
--- a/command.c
+++ b/command.c
{ { '+', RGHT, 0 }, CMD_VOLUME_UP, "Increase volume" },
{ { '-', LEFT, 0 }, CMD_VOLUME_DOWN, "Decrease volume" },
- { { 'w', 0, 0 }, CMD_TOGGLE_FIND_WRAP, "Toggle find mode" },
+ { { 'w', 0, 0 }, CMD_TOGGLE_FIND_WRAP, "Toggle find mode" },
+ { { 'U', 0, 0 }, CMD_TOGGLE_AUTOCENTER, "Toggle auto center mode" },
{ { ' ', 0, 0 }, CMD_SELECT, "Select/deselect song in playlist" },
{ { DEL, 'd', 0 }, CMD_DELETE, "Delete song from playlist" },
diff --git a/command.h b/command.h
index a7e08555b6cc0f35867536f45e806521f8b61e70..ba8de80c98059cc2086b67532999454efc1bf077 100644 (file)
--- a/command.h
+++ b/command.h
CMD_VOLUME_DOWN,
CMD_SAVE_PLAYLIST,
CMD_TOGGLE_FIND_WRAP,
+ CMD_TOGGLE_AUTOCENTER,
CMD_LIST_PREVIOUS,
CMD_LIST_NEXT,
CMD_LIST_FIRST,
index 5969c85baf806949cd896196376900134a51b897..6def7b638388863bed664b181a87227706ad3c2a 100644 (file)
--- a/conf.c
+++ b/conf.c
/* configuration field names */
#define CONF_ENABLE_COLORS "enable_colors"
+#define CONF_AUTO_CENTER "auto_center"
+
+/* configuration field names - colors */
#define CONF_COLOR_BACKGROUND "background_color"
#define CONF_COLOR_TITLE "title_color"
#define CONF_COLOR_LINE "line_color"
return COLOR_CYAN;
else if( !strcasecmp(str,"white") )
return COLOR_WHITE;
-#if 0
- else if( !strcasecmp(str,"grey") )
- return COLOR_BLACK | A_BOLD;
- else if( !strcasecmp(str,"brightred") )
- return COLOR_RED | A_BOLD;
- else if( !strcasecmp(str,"brightgreen") )
- return COLOR_GREEN | A_BOLD;
- else if( !strcasecmp(str,"brightyellow") )
- return COLOR_YELLOW | A_BOLD;
- else if( !strcasecmp(str,"brightblue") )
- return COLOR_BLUE | A_BOLD;
- else if( !strcasecmp(str,"brightmagenta") )
- return COLOR_MAGENTA | A_BOLD;
- else if( !strcasecmp(str,"brightcyan") )
- return COLOR_CYAN | A_BOLD;
- else if( !strcasecmp(str,"brightwhite") )
- return COLOR_WHITE | A_BOLD;
-#endif
fprintf(stderr,"Warning: unknown color %s\n", str);
return -1;
}
options->enable_colors = str2bool(value);
match_found = 1;
}
+ /* auto center */
+ else if( !strcasecmp(CONF_AUTO_CENTER, name) )
+ {
+ options->auto_center = str2bool(value);
+ match_found = 1;
+ }
/* background color */
else if( !strcasecmp(CONF_COLOR_BACKGROUND, name) )
{
diff --git a/doc/ncmpcrc.sample b/doc/ncmpcrc.sample
index 98d34c69958ad7df3896087af87c004eec6e1c8f..bebae08171c416e6828b3ab32a152fe55eb89121 100644 (file)
--- a/doc/ncmpcrc.sample
+++ b/doc/ncmpcrc.sample
-#
-# Configuration file for ncmpc (~/.ncmpcrc)
-#
+##
+## Configuration file for ncmpc (~/.ncmpcrc)
+##
+## auto center (center the playing track in the playlist)
+#auto_center = no
-#
-# Color configuration
-#
-# colors: black,red,green,yellow,blue,magenta,cyan,white
-#
+##
+## Color configuration
+##
+## colors: black,red,green,yellow,blue,magenta,cyan,white
+##
-# enable/disable colors
-enable_colors = yes
+## enable/disable colors
+#enable_colors = yes
-# background color
+## background color
#background_color = blue
-# text colors
+## text colors
#title_color = white
#line_color = green
#list_color = yellow
#alert_color = yellow
-#
-# Key bindings - NOT IMPLEMENTED
-#
+##
+## Key bindings - NOT IMPLEMENTED
+##
# key_up = 13
-#
-# Key names - NOT IMPLEMENTED
-#
+##
+## Key names - NOT IMPLEMENTED
+##
#key_name 13 Enter
-#
+
diff --git a/screen.c b/screen.c
index aabc6f0334b5b53e3a2fd46cef6730f832ec9e20..efd93d1fec9e76f903b3229626bb3aa9a9c700f7 100644 (file)
--- a/screen.c
+++ b/screen.c
if(clear)
{
- wclear(w);
+ wmove(w, 0, 0);
+ wclrtoeol(w);
}
if(prev_volume!=volume || clear)
}
mvwaddstr(w, 0, screen->top_window.cols-12, buf);
+#if 1
if( options.enable_colors )
wattron(w, LINE_COLORS);
mvwhline(w, 1, 0, ACS_HLINE, screen->top_window.cols);
if( options.enable_colors )
wattroff(w, LINE_COLORS);
+#else
+ if( options.enable_colors )
+ wattron(w, LINE_COLORS);
+
+ mvwhline(w, 1, 0, ACS_HLINE, screen->top_window.cols);
+ wmove(w,1,screen->top_window.cols-6);
+ waddstr(w, "[rzx]");
+
+ if( options.enable_colors )
+ wattroff(w, LINE_COLORS);
+
+#endif
wnoutrefresh(w);
}
double p;
int width;
- if( c->status==NULL || !IS_PLAYING(c->status->state) )
+ if( c->status==NULL || IS_STOPPED(c->status->state) )
{
mvwhline(screen->progress_window.w, 0, 0, ACS_HLINE,
screen->progress_window.cols);
screen->buf_size = screen->cols;
screen->findbuf = NULL;
screen->painted = 0;
+ screen->input_timestamp = time(NULL);
/* create top window */
screen->top_window.rows = 2;
int n;
screen_mode_t new_mode = screen->mode;
+ screen->input_timestamp = time(NULL);
switch(screen->mode)
{
case SCREEN_PLAY_WINDOW:
screen_status_printf("Find mode: %s",
options.find_wrap ? "Wrapped" : "Normal");
break;
+ case CMD_TOGGLE_AUTOCENTER:
+ options.auto_center = !options.auto_center;
+ screen_status_printf("Auto center mode: %s",
+ options.auto_center ? "On" : "Off");
+ break;
case CMD_SCREEN_PREVIOUS:
if( screen->mode > SCREEN_PLAY_WINDOW )
new_mode = screen->mode - 1;
diff --git a/screen_help.c b/screen_help.c
index 09349a361b1242a037af9bb5d6d5b05bd59d263a..d2e8086af345659eb3bbf8e3fcd998409808d12b 100644 (file)
--- a/screen_help.c
+++ b/screen_help.c
{ 0, CMD_SAVE_PLAYLIST, "Save playlist" },
{ 0, CMD_REPEAT, "Toggle repeat mode" },
{ 0, CMD_RANDOM, "Toggle random mode" },
+ { 0, CMD_SCREEN_UPDATE, "Center playing track" },
+ { 0, CMD_TOGGLE_AUTOCENTER, "Toggle auto center" },
{ 0, CMD_NONE, " " },
{ 0, CMD_NONE, " " },
{ 1, CMD_NONE, " Keys - Browse screen " },
diff --git a/screen_play.c b/screen_play.c
index 151402def525c6ea38c5f4581ed1386b03ea209d..c9fd248ebea50f172bf432d1530099413164582a 100644 (file)
--- a/screen_play.c
+++ b/screen_play.c
#include <ncurses.h>
#include "config.h"
+#include "options.h"
#include "support.h"
#include "libmpdclient.h"
#include "mpc.h"
return mpc_get_song_name(song);
}
+static int
+center_playing_item(screen_t *screen, mpd_client_t *c)
+{
+ list_window_t *lw = screen->playlist;
+ int length = c->playlist_length;
+ int offset = lw->selected-lw->start;
+
+ if( !lw || length<lw->rows || !IS_PLAYING(c->status->state) )
+ return 0;
+
+ /* try to center the song that are playing */
+ lw->start = c->song_id-(lw->rows/2);
+ if( lw->start+lw->rows > length )
+ lw->start = length-lw->rows;
+ if( lw->start<0 )
+ lw->start=0;
+
+ /* make sure the cursor is in the window */
+ lw->selected = lw->start+offset;
+ list_window_check_selected(lw, length);
+
+ lw->clear = 1;
+ lw->repaint = 1;
+
+ return 0;
+}
+
static int
handle_save_playlist(screen_t *screen, mpd_client_t *c)
{
void
play_update(screen_t *screen, mpd_client_t *c)
{
+ if( options.auto_center )
+ {
+ static int prev_song_id = 0;
+
+ if( prev_song_id != c->song_id )
+ {
+ center_playing_item(screen, c);
+ prev_song_id = c->song_id;
+ }
+ }
+
if( c->playlist_updated )
{
if( screen->playlist->selected >= c->playlist_length )
case CMD_SAVE_PLAYLIST:
handle_save_playlist(screen, c);
return 1;
+ case CMD_SCREEN_UPDATE:
+ center_playing_item(screen, c);
+ return 1;
case CMD_LIST_FIND:
case CMD_LIST_RFIND:
case CMD_LIST_FIND_NEXT: