diff --git a/screen.c b/screen.c
index 86269512527dc1ec8a5a37010e56e220d0917619..aabc6f0334b5b53e3a2fd46cef6730f832ec9e20 100644 (file)
--- a/screen.c
+++ b/screen.c
paint_top_window(char *header, int volume, int clear)
{
static int prev_volume = -1;
+ static int prev_header_len = -1;
WINDOW *w = screen->top_window.w;
+ if(prev_header_len!=strlen(header))
+ {
+ prev_header_len = strlen(header);
+ clear = 1;
+ }
+
if(clear)
{
wclear(w);
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);
- wrefresh(w);
+ wnoutrefresh(w);
}
}
{
mvwhline(screen->progress_window.w, 0, 0, ACS_HLINE,
screen->progress_window.cols);
- wrefresh(screen->progress_window.w);
+ wnoutrefresh(screen->progress_window.w);
return;
}
screen->progress_window.cols);
whline(screen->progress_window.w, '=', width-1);
mvwaddch(screen->progress_window.w, 0, width-1, 'O');
- wrefresh(screen->progress_window.w);
+ wnoutrefresh(screen->progress_window.w);
}
static void
if( (IS_PLAYING(status->state) || IS_PAUSED(status->state)) && song )
{
- // my_mvwaddstr(w, 0, x, mpc_get_song_name(song), COLOR_PAIR(2));
mvwaddstr(w, 0, x, mpc_get_song_name(song));
}
" [%i:%02i/%i:%02i] ",
status->elapsedTime/60, status->elapsedTime%60,
status->totalTime/60, status->totalTime%60 );
- //my_mvwaddstr(w, 0, x, screen->buf, COLOR_PAIR(1));
mvwaddstr(w, 0, x, screen->buf);
}
-#if 1
+#if 0
else if( c->status->state == MPD_STATUS_STATE_STOP )
{
time_t timep;
#endif
- wrefresh(w);
+ wnoutrefresh(w);
}
screen->playlist = list_window_free(screen->playlist);
screen->filelist = list_window_free(screen->filelist);
screen->helplist = list_window_free(screen->helplist);
- free(screen->buf);
- free(screen->findbuf);
- free(screen);
+ g_free(screen->buf);
+ g_free(screen->findbuf);
+ g_free(screen);
screen = NULL;
}
return 0;
wattron(w, A_BOLD);
my_waddstr(w, msg, ALERT_COLORS);
wattroff(w, A_BOLD);
- wrefresh(w);
+ wnoutrefresh(w);
screen->status_timestamp = time(NULL);
}
screen_init(void)
{
/* initialize the curses library */
- initscr();
- start_color();
- if( options.enable_colors )
+ initscr();
+ if( has_colors() )
{
- init_pair(1, options.title_color, options.bg_color);
- init_pair(2, options.line_color, options.bg_color);
- init_pair(3, options.list_color, options.bg_color);
- init_pair(4, options.progress_color, options.bg_color);
- init_pair(5, options.status_color, options.bg_color);
- init_pair(6, options.alert_color, options.bg_color);
+ start_color();
+ if( options.enable_colors )
+ {
+ init_pair(1, options.title_color, options.bg_color);
+ init_pair(2, options.line_color, options.bg_color);
+ init_pair(3, options.list_color, options.bg_color);
+ init_pair(4, options.progress_color, options.bg_color);
+ init_pair(5, options.status_color, options.bg_color);
+ init_pair(6, options.alert_color, options.bg_color);
+ }
+ else
+ use_default_colors();
+ }
+ else if( options.enable_colors )
+ {
+ fprintf(stderr, "Terminal lacks color capabilities.\n");
+ options.enable_colors = 0;
}
- else
- use_default_colors();
/* tell curses not to do NL->CR/NL on output */
nonl();
/* return from getch() without blocking */
// nodelay(stdscr, TRUE);
keypad(stdscr, TRUE);
- timeout(100); /*void wtimeout(WINDOW *win, int delay);*/
+ timeout(SCREEN_TIMEOUT);
if( COLS<SCREEN_MIN_COLS || LINES<SCREEN_MIN_ROWS )
{
exit(EXIT_FAILURE);
}
- screen = malloc(sizeof(screen_t));
+ screen = g_malloc(sizeof(screen_t));
memset(screen, 0, sizeof(screen_t));
screen->mode = SCREEN_PLAY_WINDOW;
screen->cols = COLS;
screen->rows = LINES;
- screen->buf = malloc(screen->cols);
+ screen->buf = g_malloc(screen->cols);
screen->buf_size = screen->cols;
screen->findbuf = NULL;
screen->painted = 0;
screen->helplist = list_window_init( screen->main_window.w,
screen->main_window.cols,
screen->main_window.rows );
- leaveok(screen->main_window.w, TRUE);
+
+ // leaveok(screen->main_window.w, TRUE); temporary disabled
keypad(screen->main_window.w, TRUE);
/* create progress window */
/* set background attributes */
wbkgd(screen->main_window.w, LIST_COLORS);
wbkgd(screen->top_window.w, TITLE_COLORS);
- wbkgd(screen->playlist->w, LIST_COLORS);
- wbkgd(screen->filelist->w, LIST_COLORS);
- wbkgd(screen->helplist->w, LIST_COLORS);
wbkgd(screen->progress_window.w, PROGRESS_COLORS);
wbkgd(screen->status_window.w, STATUS_COLORS);
}
paint_progress_window(c);
paint_status_window(c);
screen->painted = 1;
+ wmove(screen->main_window.w, 0, 0); wnoutrefresh(screen->main_window.w);
+ doupdate();
}
void
screen_update(mpd_client_t *c)
{
+ static int repeat = -1;
+ static int random = -1;
+ list_window_t *lw = NULL;
+
if( !screen->painted )
return screen_paint(c);
+ if( repeat<0 )
+ {
+ repeat = c->status->repeat;
+ random = c->status->random;
+ }
+ if( repeat != c->status->repeat )
+ screen_status_printf("Repeat is %s",
+ c->status->repeat ? "On" : "Off");
+ if( random != c->status->random )
+ screen_status_printf("Random is %s",
+ c->status->random ? "On" : "Off");
+
+ repeat = c->status->repeat;
+ random = c->status->random;
+
switch(screen->mode)
{
case SCREEN_PLAY_WINDOW:
paint_top_window(TOP_HEADER_PLAY, c->status->volume, 0);
play_update(screen, c);
+ lw = screen->playlist;
break;
case SCREEN_FILE_WINDOW:
paint_top_window(file_get_header(c), c->status->volume, 0);
file_update(screen, c);
+ lw = screen->filelist;
break;
case SCREEN_SEARCH_WINDOW:
paint_top_window(TOP_HEADER_SEARCH, c->status->volume, 0);
case SCREEN_HELP_WINDOW:
paint_top_window(TOP_HEADER_HELP, c->status->volume, 0);
help_update(screen, c);
+ lw = screen->helplist;
break;
}
paint_progress_window(c);
paint_status_window(c);
+ wmove(screen->main_window.w, LW_ROW(lw), 0);
+ wnoutrefresh(screen->main_window.w);
+ doupdate();
}
void
screen_cmd(mpd_client_t *c, command_t cmd)
{
int n;
- // char buf[256];
screen_mode_t new_mode = screen->mode;
switch(screen->mode)
n = !c->status->repeat;
mpd_sendRepeatCommand(c->connection, n);
mpd_finishCommand(c->connection);
- screen_status_printf("Repeat is %s", n ? "On" : "Off");
break;
case CMD_RANDOM:
n = !c->status->random;
mpd_sendRandomCommand(c->connection, n);
mpd_finishCommand(c->connection);
- screen_status_printf("Random is %s", n ? "On" : "Off");
break;
case CMD_VOLUME_UP:
if( c->status->volume!=MPD_STATUS_NO_VOLUME && c->status->volume<100 )
screen_status_printf("Volume %d%%", c->status->volume);
}
break;
+ case CMD_TOGGLE_FIND_WRAP:
+ options.find_wrap = !options.find_wrap;
+ screen_status_printf("Find mode: %s",
+ options.find_wrap ? "Wrapped" : "Normal");
+ break;
case CMD_SCREEN_PREVIOUS:
if( screen->mode > SCREEN_PLAY_WINDOW )
new_mode = screen->mode - 1;
break;
case CMD_QUIT:
exit(EXIT_SUCCESS);
- case CMD_LIST_FIND:
- case CMD_LIST_FIND_NEXT:
- case CMD_NONE:
- case CMD_DELETE:
- case CMD_SELECT:
- case CMD_LIST_PREVIOUS:
- case CMD_LIST_NEXT:
- case CMD_LIST_FIRST:
- case CMD_LIST_LAST:
- case CMD_LIST_NEXT_PAGE:
- case CMD_LIST_PREVIOUS_PAGE:
+ default:
break;
}
}
-;
+