Code

screen: moved list_window mouse code to list_window.c
[ncmpc.git] / src / screen.c
index e0fa3e1c73b03ea96b5fd22e006fcf5880c45c90..a76438b9c6f9b095f016fbaea11d6f364b5cf6c2 100644 (file)
@@ -43,7 +43,6 @@
 #define SCREEN_ARTIST_ID       2
 #define SCREEN_HELP_ID         100
 #define SCREEN_KEYDEF_ID       101
-#define SCREEN_CLOCK_ID        102
 #define SCREEN_SEARCH_ID       103
 #define SCREEN_LYRICS_ID          104
 
@@ -62,9 +61,6 @@ extern const struct screen_functions screen_search;
 #ifdef ENABLE_KEYDEF_SCREEN
 extern const struct screen_functions screen_keydef;
 #endif
-#ifdef ENABLE_CLOCK_SCREEN
-extern const struct screen_functions screen_clock;
-#endif
 extern const struct screen_functions screen_lyrics;
 
 typedef struct screen_functions * (*screen_get_mode_functions_fn_t) (void);
@@ -87,9 +83,6 @@ static const struct
 #ifdef ENABLE_KEYDEF_SCREEN
        { SCREEN_KEYDEF_ID, "keydef", &screen_keydef },
 #endif
-#ifdef ENABLE_CLOCK_SCREEN
-       { SCREEN_CLOCK_ID, "clock", &screen_clock },
-#endif
 #ifdef ENABLE_LYRICS_SCREEN
        { SCREEN_LYRICS_ID, "lyrics", &screen_lyrics },
 #endif
@@ -324,6 +317,7 @@ paint_status_window(mpdclient_t *c)
        mpd_Status *status = c->status;
        mpd_Song *song = c->song;
        int elapsedTime = 0;
+       char bitrate[16];
        const char *str = NULL;
        int x = 0;
 
@@ -364,16 +358,25 @@ paint_status_window(mpdclient_t *c)
 
                        if( c->song && seek_id == c->song->id )
                                elapsedTime = seek_target_time;
+
+                       /* display bitrate if visible-bitrate is true */
+                       if (options.visible_bitrate) {
+                               g_snprintf(bitrate, 16,
+                                          " [%d kbps]", status->bitRate);
+                       } else {
+                               bitrate[0] = '\0';
+                       }
+
                        /*write out the time, using hours if time over 60 minutes*/
                        if (c->status->totalTime > 3600) {
                                g_snprintf(screen.buf, screen.buf_size,
-                                          " [%i:%02i:%02i/%i:%02i:%02i]",
-                                          elapsedTime/3600, (elapsedTime%3600)/60, elapsedTime%60,
+                                          "%s [%i:%02i:%02i/%i:%02i:%02i]",
+                                          bitrate, elapsedTime/3600, (elapsedTime%3600)/60, elapsedTime%60,
                                           status->totalTime/3600, (status->totalTime%3600)/60,  status->totalTime%60);
                        } else {
                                g_snprintf(screen.buf, screen.buf_size,
-                                          " [%i:%02i/%i:%02i]",
-                                          elapsedTime/60, elapsedTime%60,
+                                          "%s [%i:%02i/%i:%02i]",
+                                          bitrate, elapsedTime/60, elapsedTime%60,
                                           status->totalTime/60,   status->totalTime%60 );
                        }
                } else {
@@ -426,8 +429,6 @@ screen_exit(void)
 {
        guint i;
 
-       endwin();
-
        if (mode_fn->close != NULL)
                mode_fn->close();
 
@@ -528,30 +529,9 @@ screen_status_printf(const char *format, ...)
 }
 
 void
-ncurses_init(void)
+screen_init(mpdclient_t *c)
 {
-
-       /* initialize the curses library */
-       initscr();
-       /* initialize color support */
-       colors_start();
-       /* tell curses not to do NL->CR/NL on output */
-       nonl();
-       /*  use raw mode (ignore interrupt,quit,suspend, and flow control ) */
-#ifdef ENABLE_RAW_MODE
-       //  raw();
-#endif
-       /* don't echo input */
-       noecho();
-       /* set cursor invisible */
-       curs_set(0);
-       /* enable extra keys */
-       keypad(stdscr, TRUE);
-       /* initialize mouse support */
-#ifdef HAVE_GETMOUSE
-       if (options.enable_mouse)
-               mousemask(ALL_MOUSE_EVENTS, NULL);
-#endif
+       guint i;
 
        if (COLS < SCREEN_MIN_COLS || LINES < SCREEN_MIN_ROWS) {
                fprintf(stderr, _("Error: Screen to small!\n"));
@@ -621,12 +601,6 @@ ncurses_init(void)
        }
 
        refresh();
-}
-
-void
-screen_init(mpdclient_t *c)
-{
-       guint i;
 
        /* initialize screens */
        for (i = 0; i < NUM_SCREENS; ++i) {
@@ -721,7 +695,8 @@ screen_update(mpdclient_t *c)
        }
 
        /* update title/header window */
-       if (welcome && screen.last_cmd==CMD_NONE &&
+       if (welcome && options.welcome_screen_list &&
+           screen.last_cmd==CMD_NONE &&
            time(NULL)-screen.start_timestamp <= SCREEN_WELCOME_TIME)
                paint_top_window("", c, 0);
        else if (mode_fn->get_title != NULL) {
@@ -762,9 +737,7 @@ screen_idle(mpdclient_t *c)
 
 #ifdef HAVE_GETMOUSE
 int
-screen_get_mouse_event(mpdclient_t *c,
-                      list_window_t *lw, int lw_length,
-                      unsigned long *bstate, int *row)
+screen_get_mouse_event(mpdclient_t *c, unsigned long *bstate, int *row)
 {
        MEVENT event;
 
@@ -781,24 +754,6 @@ screen_get_mouse_event(mpdclient_t *c,
                return 1;
        }
 
-       /* if the even occured above the list window move up */
-       if (*row < 0 && lw) {
-               if (event.bstate & BUTTON3_CLICKED)
-                       list_window_first(lw);
-               else
-                       list_window_previous_page(lw);
-               return 1;
-       }
-
-       /* if the even occured below the list window move down */
-       if ((unsigned)*row >= lw->rows && lw) {
-               if (event.bstate & BUTTON3_CLICKED)
-                       list_window_last(lw, lw_length);
-               else
-                       list_window_next_page(lw, lw_length);
-               return 1;
-       }
-
        return 0;
 }
 #endif
@@ -810,15 +765,20 @@ screen_client_cmd(mpdclient_t *c, command_t cmd)
                return 0;
 
        switch(cmd) {
+               /*
        case CMD_PLAY:
                mpdclient_cmd_play(c, MPD_PLAY_AT_BEGINNING);
                break;
+               */
        case CMD_PAUSE:
                mpdclient_cmd_pause(c, !IS_PAUSED(c->status->state));
                break;
        case CMD_STOP:
                mpdclient_cmd_stop(c);
                break;
+       case CMD_CROP:
+               mpdclient_cmd_crop(c);
+               break;
        case CMD_SEEK_FORWARD:
                if (!IS_STOPPED(c->status->state)) {
                        if (c->song && seek_id != c->song->id) {
@@ -948,9 +908,6 @@ screen_cmd(mpdclient_t *c, command_t cmd)
        case CMD_SCREEN_KEYDEF:
                switch_screen_mode(SCREEN_KEYDEF_ID, c);
                break;
-       case CMD_SCREEN_CLOCK:
-               switch_screen_mode(SCREEN_CLOCK_ID, c);
-               break;
        case CMD_SCREEN_LYRICS:
                switch_screen_mode(SCREEN_LYRICS_ID, c);
                break;