<s> from __future__ import absolute_import <EOL> import curses <EOL> from curses import panel <EOL> from pytify . strategy import get_pytify_class_by_platform <EOL> """<STR_LIT>""" <EOL> class Menu ( object ) : <EOL> def __init__ ( self , items , stdscreen ) : <EOL> self . pytify = get_pytify_class_by_platform ( ) ( ) <EOL> self . window = stdscreen . subwin ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> self . window . keypad ( <NUM_LIT:1> ) <EOL> self . panel = panel . new_panel ( self . window ) <EOL> self . panel . hide ( ) <EOL> panel . update_panels ( ) <EOL> self . position = <NUM_LIT:2> <EOL> self . items = items <EOL> self . song_length = len ( items ) - <NUM_LIT:1> <EOL> self . items . append ( '<STR_LIT:U+0020>' ) <EOL> self . items . append ( '<STR_LIT>' ) <EOL> self . items . append ( '<STR_LIT>' ) <EOL> self . items . append ( '<STR_LIT>' ) <EOL> self . items . append ( '<STR_LIT>' ) <EOL> self . items . append ( '<STR_LIT>' ) <EOL> def navigate ( self , n ) : <EOL> self . position += n <EOL> if self . position < <NUM_LIT:2> : <EOL> self . position = <NUM_LIT:2> <EOL> elif self . position > self . song_length : <EOL> self . position = self . song_length <EOL> def display ( self ) : <EOL> self . panel . top ( ) <EOL> self . panel . show ( ) <EOL> self . window . clear ( ) <EOL> while True : <EOL> self . window . refresh ( ) <EOL> curses . doupdate ( ) <EOL> for index , item in enumerate ( self . items ) : <EOL> if index == self . position : <EOL> mode = curses . A_REVERSE <EOL> else : <EOL> mode = curses . A_NORMAL <EOL> self . window . addstr ( index , <NUM_LIT:1> , str ( item ) , mode ) <EOL> key = self . window . getch ( ) <EOL> if key in [ curses . KEY_ENTER , ord ( '<STR_LIT:\n>' ) ] : <EOL> self . pytify . listen ( int ( self . position - <NUM_LIT:1> ) ) <EOL> elif key == curses . KEY_UP : <EOL> self . navigate ( - <NUM_LIT:1> ) <EOL> elif key == curses . KEY_DOWN : <EOL> self . navigate ( <NUM_LIT:1> ) <EOL> elif key == curses . KEY_LEFT : <EOL> self . pytify . prev ( ) <EOL> elif key == curses . KEY_RIGHT : <EOL> self . pytify . next ( ) <EOL> elif key == <NUM_LIT:32> : <EOL> self . pytify . play_pause ( ) <EOL> elif key == <NUM_LIT> : <EOL> break <EOL> self . window . clear ( ) <EOL> self . panel . hide ( ) <EOL> panel . update_panels ( ) <EOL> curses . doupdate ( ) </s>
