summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e02744c)
raw | patch | inline | side by side (parent: e02744c)
author | Kalle Wallin <kaw@linux.se> | |
Wed, 9 Jun 2004 17:24:11 +0000 (17:24 +0000) | ||
committer | Kalle Wallin <kaw@linux.se> | |
Wed, 9 Jun 2004 17:24:11 +0000 (17:24 +0000) |
Changed arguments to the get_title callback
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@1420 09075e82-0dd4-0310-85a5-a0d7c8717e4f
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@1420 09075e82-0dd4-0310-85a5-a0d7c8717e4f
src/screen.c | patch | blob | history | |
src/screen.h | patch | blob | history |
diff --git a/src/screen.c b/src/screen.c
index d77faf269904f3ad4c037a7e20ee7f2ac2ae95c9..d50e5925feff28e4b916595cd0549a14b7eb322e 100644 (file)
--- a/src/screen.c
+++ b/src/screen.c
#include "config.h"
#include "ncmpc.h"
+#include "support.h"
#include "libmpdclient.h"
#include "mpc.h"
#include "command.h"
#endif
+static gboolean welcome = TRUE;
static screen_t *screen = NULL;
static screen_functions_t *mode_fn = NULL;
wnoutrefresh(screen->progress_window.w);
}
-#ifdef ENABLE_SCROLLING
-static char *
-scroll_string(char *str, char *sep, int width)
-{
- static int offset = 0;
- static time_t t = 0;
- char *tmp, *buf;
- size_t len;
-
- if( offset==0 )
- {
- offset++;
- return g_strdup(str);
- }
-
- /* create a buffer containing the string and the separator */
- tmp = g_malloc(strlen(str)+strlen(sep)+1);
- strcpy(tmp, str);
- strcat(tmp, sep);
- len = strlen(tmp);
-
- if( offset >= len )
- offset = 0;
-
- /* create the new scrolled string */
- buf = g_malloc(width+1);
- strncpy(buf, tmp+offset, width);
- if( strlen(buf) < width )
- strncat(buf, tmp, width-strlen(buf));
-
- if( time(NULL)-t >= 1 )
- {
- t = time(NULL);
- offset++;
- }
- g_free(tmp);
- return buf;
-}
-#endif
-
static void
paint_status_window(mpd_client_t *c)
{
switch(status->state)
{
- case MPD_STATUS_STATE_STOP:
- waddstr(w, _("Stopped! "));
- break;
case MPD_STATUS_STATE_PLAY:
waddstr(w, _("Playing:"));
break;
case MPD_STATUS_STATE_PAUSE:
waddstr(w, _("[Paused]"));
break;
+ case MPD_STATUS_STATE_STOP:
default:
break;
}
#ifdef ENABLE_SCROLLING
if( strlen(songname) > width )
{
- char *tmp = scroll_string(songname, " *** ", width);
+ static scroll_state_t st = { 0, 0 };
+ char *tmp = strscroll(songname, " *** ", width, &st);
+
strcpy(songname, tmp);
- g_free(tmp);
+ g_free(tmp);
}
#endif
mvwaddnstr(w, 0, x, songname, width);
colors_start();
/* tell curses not to do NL->CR/NL on output */
nonl();
- /* take input chars one at a time, no wait for \n */
- cbreak();
+ /* use raw mode (ignore interrupt,quit,suspend, and flow control ) */
+ raw();
/* don't echo input */
noecho();
/* set cursor invisible */
keypad(stdscr, TRUE);
/* return from getch() without blocking */
timeout(SCREEN_TIMEOUT);
+
if( COLS<SCREEN_MIN_COLS || LINES<SCREEN_MIN_ROWS )
{
{
/* paint the title/header window */
if( mode_fn && mode_fn->get_title )
- paint_top_window(mode_fn->get_title(), c, 1);
+ paint_top_window(mode_fn->get_title(screen->buf,screen->buf_size), c, 1);
else
paint_top_window("", c, 1);
static int random = -1;
static int crossfade = -1;
static int dbupdate = -1;
- static int welcome = 1;
list_window_t *lw = NULL;
if( !screen->painted )
paint_top_window("", c, 0);
else if( mode_fn && mode_fn->get_title )
{
- paint_top_window(mode_fn->get_title(), c, 0);
- welcome = 0;
+ paint_top_window(mode_fn->get_title(screen->buf,screen->buf_size), c, 0);
+ welcome = FALSE;
}
else
paint_top_window("", c, 0);
screen->input_timestamp = time(NULL);
screen->last_cmd = cmd;
+ welcome = FALSE;
if( mode_fn && mode_fn->cmd && mode_fn->cmd(screen, c, cmd) )
return;
diff --git a/src/screen.h b/src/screen.h
index f674b1cffa64db216f7bcdae94147b0fa0120047..fe843daa6d2c14f524b69be1688374b237fda28b 100644 (file)
--- a/src/screen.h
+++ b/src/screen.h
typedef void (*screen_paint_fn_t) (screen_t *screen, mpd_client_t *c);
typedef void (*screen_update_fn_t) (screen_t *screen, mpd_client_t *c);
typedef int (*screen_cmd_fn_t) (screen_t *scr, mpd_client_t *c, command_t cmd);
-typedef char * (*screen_title_fn_t) (void);
+typedef char * (*screen_title_fn_t) (char *s, size_t size);
typedef list_window_t * (*screen_get_lw_fn_t) (void);
typedef struct