summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f674c3f)
raw | patch | inline | side by side (parent: f674c3f)
author | Kalle Wallin <kaw@linux.se> | |
Tue, 13 Jul 2004 17:31:53 +0000 (17:31 +0000) | ||
committer | Kalle Wallin <kaw@linux.se> | |
Tue, 13 Jul 2004 17:31:53 +0000 (17:31 +0000) |
ChangeLog | patch | blob | history | |
doc/config.sample | patch | blob | history | |
src/conf.c | patch | blob | history | |
src/ncmpc.h | patch | blob | history | |
src/options.c | patch | blob | history | |
src/options.h | patch | blob | history | |
src/screen.c | patch | blob | history | |
src/screen.h | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index 5e2279601cf8a0e3105d4d449125cbe99ead5fb6..1978644f2ae69183812d1cec471af7a43f204f32 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2004-07-13 Kalle Wallin <kaw@linux.se>
+ * command.c: added my_wgetch() function,
+ Ctrl-C, Ctrl-Z are now hard coded to SIGINT and SIGSTOP
+ * options.c: added options --mouse and --no-mouse
+ * Crossfade time can now be definied in the conf file (crossfade-time)
+
2004-07-12 Kalle Wallin <kaw@linux.se>
* options.c: fixed short option handling for multiple short options
at once (-abcde)
diff --git a/doc/config.sample b/doc/config.sample
index 0630296d5bc3c99a7d21bb1513b6f29eceb36692..5d53e39d21c7ec50d23b57a9302f9fb74008bc45 100644 (file)
--- a/doc/config.sample
+++ b/doc/config.sample
## xterm title format
#xterm-title-format = "ncmpc: [ %name%|[%artist% - ]%title%|%file%]"
+## enable mouse events
+#enable-mouse = no
+
+## mpd crossfade time
+##crossfade-time = 10
+
##
## Color configuration
##
diff --git a/src/conf.c b/src/conf.c
index b31b7b1735c8fb09e82152f75c0e88a38400e51a..740939d10ec432594cd229e9067c588d8e0ce4c2 100644 (file)
--- a/src/conf.c
+++ b/src/conf.c
#define CONF_VISIBLE_BELL "visible-bell"
#define CONF_XTERM_TITLE "set-xterm-title"
#define CONF_ENABLE_MOUSE "enable-mouse"
+#define CONF_CROSSFADE_TIME "crossfade-time"
typedef enum {
KEY_PARSER_UNKNOWN,
{
options->enable_mouse = str2bool(value);
}
+ else if( !strcasecmp(CONF_CROSSFADE_TIME, name) )
+ {
+ options->crossfade_time = atoi(value);
+ }
else
{
match_found = 0;
diff --git a/src/ncmpc.h b/src/ncmpc.h
index 7c1d519584594eb00145dc3cc416c7be84d28e19..019ce6893abf95f4b9745551ac19b3fca8ced00f 100644 (file)
--- a/src/ncmpc.h
+++ b/src/ncmpc.h
#define YES _("y")
#define NO _("n")
+/* mpd crossfade time [s] */
+#define DEFAULT_CROSSFADE_TIME 10
+
/* welcome message time [s] */
#define SCREEN_WELCOME_TIME 10
diff --git a/src/options.c b/src/options.c
index 514ba544bba1b6f7853b50ee889655e33b46c86a..4f1100f9d9f0ce2fed50b9f4eea25d5c32d4f647 100644 (file)
--- a/src/options.c
+++ b/src/options.c
options.find_wrap = TRUE;
options.wide_cursor = TRUE;
options.audible_bell = TRUE;
+ options.crossfade_time = DEFAULT_CROSSFADE_TIME;
return &options;
}
diff --git a/src/options.h b/src/options.h
index 1a4e4b61e7b4d8ecc0d1b89ba3c505392e77e896..e4d61e87828a2c0b941d94d2171e666bab2c2baf 100644 (file)
--- a/src/options.h
+++ b/src/options.h
char *status_format;
char *xterm_title_format;
int port;
+ int crossfade_time;
gboolean reconnect;
gboolean debug;
gboolean find_wrap;
diff --git a/src/screen.c b/src/screen.c
index f7145be6b03ffe80e4b435e9e235a0b442dd9288..eacc78f88ee7011e14c1dcc7ed7e082d0f2c515f 100644 (file)
--- a/src/screen.c
+++ b/src/screen.c
#define ENABLE_STATUS_LINE_CLOCK
#define ENABLE_SCROLLING
-#define CROSSFADE_TIME 10
-
#define STATUS_MESSAGE_TIMEOUT 3
#define STATUS_LINE_MAX_SIZE 512
+#define SCREEN_PLAYLIST_ID 0
+#define SCREEN_BROWSE_ID 1
+#define SCREEN_HELP_ID 100
+#define SCREEN_KEYDEF_ID 101
+#define SCREEN_CLOCK_ID 102
+
/* screens */
extern screen_functions_t *get_screen_playlist(void);
extern screen_functions_t *get_screen_browse(void);
extern screen_functions_t *get_screen_clock(void);
#endif
+typedef screen_functions_t * (*screen_get_mode_functions_fn_t) (void);
+
+typedef struct
+{
+ gint id;
+ gchar *name;
+ screen_get_mode_functions_fn_t get_mode_functions;
+
+} screen_mode_info_t;
+
+static screen_mode_info_t screens[] = {
+ { SCREEN_PLAYLIST_ID, "playlist", get_screen_playlist },
+ { SCREEN_BROWSE_ID, "browse", get_screen_browse },
+ { SCREEN_HELP_ID, "help", get_screen_help },
+#ifdef ENABLE_KEYDEF_SCREEN
+ { SCREEN_KEYDEF_ID, "keydef", get_screen_keydef },
+#endif
+#ifdef ENABLE_CLOCK_SCREEN
+ { SCREEN_CLOCK_ID, "clock", get_screen_clock },
+#endif
+ { -1, NULL, NULL }
+};
+
static gboolean welcome = TRUE;
static screen_t *screen = NULL;
static screen_functions_t *mode_fn = NULL;
static int seek_id = -1;
static int seek_target_time = 0;
+static gint
+lookup_mode(gint id)
+{
+ gint i=0;
+
+ while( screens[i].name )
+ {
+ if( screens[i].id == id )
+ return i;
+ i++;
+ }
+ return -1;
+}
static void
-switch_screen_mode(screen_mode_t new_mode, mpdclient_t *c)
+switch_screen_mode(gint id, mpdclient_t *c)
{
- if( new_mode == screen->mode )
+ gint new_mode;
+
+ if( id == screens[screen->mode].id )
return;
/* close the old mode */
mode_fn->close();
/* get functions for the new mode */
- switch(new_mode)
+ new_mode = lookup_mode(id);
+ if( new_mode>=0 && screens[new_mode].get_mode_functions )
{
- case SCREEN_PLAY_WINDOW:
- mode_fn = get_screen_playlist();
- break;
- case SCREEN_FILE_WINDOW:
- mode_fn = get_screen_browse();
- break;
- case SCREEN_HELP_WINDOW:
- mode_fn = get_screen_help();
- break;
-#ifdef ENABLE_KEYDEF_SCREEN
- case SCREEN_KEYDEF_WINDOW:
- mode_fn = get_screen_keydef();
- break;
-#endif
-#ifdef ENABLE_CLOCK_SCREEN
- case SCREEN_CLOCK_WINDOW:
- mode_fn = get_screen_clock();
- break;
-#endif
-
- default:
- break;
+ mode_fn = screens[new_mode].get_mode_functions();
+ screen->mode = new_mode;
}
- screen->mode = new_mode;
- screen->painted = 0;
-
- /* open the new mode */
- if( mode_fn && mode_fn->open )
- mode_fn->open(screen, c);
+ screen->painted = 0;
+
+ /* open the new mode */
+ if( mode_fn && mode_fn->open )
+ mode_fn->open(screen, c);
}
endwin();
if( screen )
{
- GList *list = g_list_first(screen->screen_list);
+ gint i;
/* close and exit all screens (playlist,browse,help...) */
- while( list )
+ i=0;
+ while( screens[i].get_mode_functions )
{
- screen_functions_t *mode_fn = list->data;
+ screen_functions_t *mode_fn = screens[i].get_mode_functions();
if( mode_fn && mode_fn->close )
mode_fn->close();
if( mode_fn && mode_fn->exit )
mode_fn->exit();
- list->data = NULL;
- list=list->next;
+
+ i++;
}
- g_list_free(screen->screen_list);
+
screen_free_string_list(screen->find_history);
g_free(screen->buf);
g_free(screen->findbuf);
void
screen_resize(void)
{
- GList *list;
+ gint i;
D("Resize rows %d->%d, cols %d->%d\n",screen->rows,LINES,screen->cols,COLS);
if( COLS<SCREEN_MIN_COLS || LINES<SCREEN_MIN_ROWS )
g_free(screen->buf);
screen->buf = g_malloc(screen->cols);
- list = g_list_first(screen->screen_list);
- while( list )
+ /* close and exit all screens (playlist,browse,help...) */
+ i=0;
+ while( screens[i].get_mode_functions )
{
- screen_functions_t *mode_fn = list->data;
+ screen_functions_t *mode_fn = screens[i].get_mode_functions();
if( mode_fn && mode_fn->resize )
mode_fn->resize(screen->main_window.cols, screen->main_window.rows);
- list=list->next;
+ i++;
}
/* ? - without this the cursor becomes visible with aterm & Eterm */
int
screen_init(mpdclient_t *c)
{
- GList *list;
+ gint i;
/* initialize the curses library */
initscr();
screen = g_malloc(sizeof(screen_t));
memset(screen, 0, sizeof(screen_t));
- screen->mode = SCREEN_PLAY_WINDOW;
+ screen->mode = 0;
screen->cols = COLS;
screen->rows = LINES;
screen->buf = g_malloc(screen->cols);
}
/* initialize screens */
- screen->screen_list = NULL;
- screen->screen_list = g_list_append(screen->screen_list,
- (gpointer) get_screen_playlist());
- screen->screen_list = g_list_append(screen->screen_list,
- (gpointer) get_screen_browse());
- screen->screen_list = g_list_append(screen->screen_list,
- (gpointer) get_screen_help());
-#ifdef ENABLE_KEYDEF_SCREEN
- screen->screen_list = g_list_append(screen->screen_list,
- (gpointer) get_screen_keydef());
-#endif
-#ifdef ENABLE_CLOCK_SCREEN
- screen->screen_list = g_list_append(screen->screen_list,
- (gpointer) get_screen_clock());
-#endif
-
- list = screen->screen_list;
- while( list )
+ i=0;
+ while( screens[i].get_mode_functions )
{
- screen_functions_t *fn = list->data;
-
+ screen_functions_t *fn = screens[i].get_mode_functions();
+
if( fn && fn->init )
fn->init(screen->main_window.w,
screen->main_window.cols,
screen->main_window.rows);
-
- list = list->next;
+
+ i++;
}
mode_fn = get_screen_playlist();
void
screen_cmd(mpdclient_t *c, command_t cmd)
{
- screen_mode_t new_mode = screen->mode;
-
screen->input_timestamp = time(NULL);
screen->last_cmd = cmd;
welcome = FALSE;
mpdclient_cmd_random(c, !c->status->random);
break;
case CMD_CROSSFADE:
- mpdclient_cmd_crossfade(c, c->status->crossfade ? 0 : CROSSFADE_TIME);
+ if( c->status->crossfade )
+ mpdclient_cmd_crossfade(c, 0);
+ else
+ mpdclient_cmd_crossfade(c, options.crossfade_time);
break;
case CMD_DB_UPDATE:
if( !c->status->updatingDb )
screen->painted = 0;
break;
case CMD_SCREEN_PREVIOUS:
- if( screen->mode > SCREEN_PLAY_WINDOW )
- new_mode = screen->mode - 1;
+ if( screen->mode > 0 )
+ switch_screen_mode(screens[screen->mode-1].id, c);
else
- new_mode = SCREEN_HELP_WINDOW-1;
- switch_screen_mode(new_mode, c);
+ switch_screen_mode(lookup_mode(SCREEN_HELP_ID)-1, c);
break;
case CMD_SCREEN_NEXT:
- new_mode = screen->mode + 1;
- if( new_mode >= SCREEN_HELP_WINDOW )
- new_mode = SCREEN_PLAY_WINDOW;
- switch_screen_mode(new_mode, c);
+ if( screens[screen->mode+1].id < SCREEN_HELP_ID )
+ switch_screen_mode(screens[screen->mode+1].id, c);
+ else
+ switch_screen_mode(screens[0].id, c);
break;
case CMD_SCREEN_PLAY:
- switch_screen_mode(SCREEN_PLAY_WINDOW, c);
+ switch_screen_mode(SCREEN_PLAYLIST_ID, c);
break;
case CMD_SCREEN_FILE:
- switch_screen_mode(SCREEN_FILE_WINDOW, c);
- break;
- case CMD_SCREEN_SEARCH:
- switch_screen_mode(SCREEN_SEARCH_WINDOW, c);
+ switch_screen_mode(SCREEN_BROWSE_ID, c);
break;
case CMD_SCREEN_HELP:
- switch_screen_mode(SCREEN_HELP_WINDOW, c);
+ switch_screen_mode(SCREEN_HELP_ID, c);
break;
-#ifdef ENABLE_KEYDEF_SCREEN
case CMD_SCREEN_KEYDEF:
- switch_screen_mode(SCREEN_KEYDEF_WINDOW, c);
+ switch_screen_mode(SCREEN_KEYDEF_ID, c);
break;
-#endif
-#ifdef ENABLE_CLOCK_SCREEN
case CMD_SCREEN_CLOCK:
- switch_screen_mode(SCREEN_CLOCK_WINDOW, c);
+ switch_screen_mode(SCREEN_CLOCK_ID, c);
break;
-#endif
case CMD_QUIT:
exit(EXIT_SUCCESS);
default:
diff --git a/src/screen.h b/src/screen.h
index c725bb13c64258ce4abdb7b12b4bfc32d696dbe5..8f95d7a86b5ae769dfba1c66d2baa270f0354012 100644 (file)
--- a/src/screen.h
+++ b/src/screen.h
#define IS_PAUSED(s) (s==MPD_STATUS_STATE_PAUSE)
#define IS_STOPPED(s) (!(IS_PLAYING(s) | IS_PAUSED(s)))
-
-typedef enum
-{
- SCREEN_PLAY_WINDOW = 0,
- SCREEN_FILE_WINDOW,
- SCREEN_HELP_WINDOW,
- SCREEN_KEYDEF_WINDOW,
- SCREEN_CLOCK_WINDOW,
- SCREEN_SEARCH_WINDOW
-
-} screen_mode_t;
-
typedef struct
{
WINDOW *w;
} window_t;
-
typedef struct
{
window_t top_window;
window_t progress_window;
window_t status_window;
- GList *screen_list;
-
/* GTime is equivalent to time_t */
GTime start_timestamp;
GTime status_timestamp;
int cols, rows;
- screen_mode_t mode;
+ //screen_mode_t mode;
+ int mode;
char *buf;
size_t buf_size;