<s> from __future__ import unicode_literals , division <EOL> import time <EOL> from curtsies import FullscreenWindow , Input , FSArray <EOL> from curtsies . fmtfuncs import red , bold , green , on_blue , yellow , on_red <EOL> import curtsies . events <EOL> class Frame ( curtsies . events . ScheduledEvent ) : <EOL> pass <EOL> class World ( object ) : <EOL> def __init__ ( self ) : <EOL> self . s = '<STR_LIT>' <EOL> def tick ( self ) : <EOL> self . s += '<STR_LIT:|>' <EOL> self . s = self . s [ max ( <NUM_LIT:1> , len ( self . s ) - <NUM_LIT> ) : ] <EOL> def process_event ( self , e ) : <EOL> self . s += str ( e ) <EOL> def realtime ( fps = <NUM_LIT:15> ) : <EOL> world = World ( ) <EOL> dt = <NUM_LIT:1> / fps <EOL> reactor = Input ( ) <EOL> schedule_next_frame = reactor . scheduled_event_trigger ( Frame ) <EOL> schedule_next_frame ( when = time . time ( ) ) <EOL> with reactor : <EOL> for e in reactor : <EOL> if isinstance ( e , Frame ) : <EOL> world . tick ( ) <EOL> print ( world . s ) <EOL> when = e . when + dt <EOL> while when < time . time ( ) : <EOL> when += dt <EOL> schedule_next_frame ( when ) <EOL> elif e == u'<STR_LIT>' : <EOL> break <EOL> else : <EOL> world . process_event ( e ) <EOL> realtime ( ) </s>
