#NEWLINE# def read( self ) : #NEWLINE# #INDENT# ' Read from windows console and update shared memory blocks. ' #NEWLINE# if ( ( self . screen_redraw_ct == 0 ) and ( not self . is_alive ( ) ) ) : #NEWLINE# #INDENT# stats = { #NEWLINE# #INDENT# 'top_offset' : 0 , #NEWLINE# 'default_attribute' : 0 , #NEWLINE# 'cursor_x' : 0 , #NEWLINE# 'cursor_y' : self . cursor_line , #NEWLINE# 'is_alive' : 0 , #NEWLINE# #UNINDENT# } #NEWLINE# self . shm_stats . write ( stats ) #NEWLINE# return #NEWLINE# #UNINDENT# self . check_commands ( ) #NEWLINE# buf_info = self . get_buffer_info ( ) #NEWLINE# curs_line = buf_info . dwCursorPosition . Y #NEWLINE# curs_col = buf_info . dwCursorPosition . X #NEWLINE# if ( ( curs_line != self . cursor_line ) or ( self . top != buf_info . srWindow . Top ) or ( self . screen_redraw_ct == CONQUE_SOLE_SCREEN_REDRAW ) ) : #NEWLINE# #INDENT# self . screen_redraw_ct = 0 #NEWLINE# read_start = self . top #NEWLINE# read_end = max ( [ ( buf_info . srWindow . Bottom + 1 ) , ( curs_line + 1 ) ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# read_start = curs_line #NEWLINE# read_end = ( curs_line + 1 ) #NEWLINE# #UNINDENT# coord = COORD ( 0 , 0 ) #NEWLINE# chars_read = ctypes . c_int ( 0 ) #NEWLINE# for i in range ( read_start , read_end ) : #NEWLINE# #INDENT# coord . Y = i #NEWLINE# res = ctypes . windll . kernel32 . ReadConsoleOutputCharacterW ( self . stdout , ctypes . byref ( self . tc ) , self . buffer_width , coord , ctypes . byref ( chars_read ) ) #NEWLINE# if ( not self . fast_mode ) : #NEWLINE# #INDENT# ctypes . windll . kernel32 . ReadConsoleOutputAttribute ( self . stdout , ctypes . byref ( self . ac ) , self . buffer_width , coord , ctypes . byref ( chars_read ) ) #NEWLINE# #UNINDENT# t = self . tc . value #NEWLINE# if ( not self . fast_mode ) : #NEWLINE# #INDENT# a = self . ac . value #NEWLINE# #UNINDENT# if ( i >= len ( self . data ) ) : #NEWLINE# #INDENT# for j in range ( len ( self . data ) , ( i + 1 ) ) : #NEWLINE# #INDENT# self . data . append ( '' ) #NEWLINE# if ( not self . fast_mode ) : #NEWLINE# #INDENT# self . attributes . append ( '' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . data [ i ] = t #NEWLINE# if ( not self . fast_mode ) : #NEWLINE# #INDENT# self . attributes [ i ] = a #NEWLINE# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# if ( self . mem_redraw_ct == CONQUE_SOLE_MEM_REDRAW ) : #NEWLINE# #INDENT# self . mem_redraw_ct = 0 #NEWLINE# for i in range ( 0 , len ( self . data ) ) : #NEWLINE# #INDENT# self . shm_output . write ( text = self . data [ i ] , start = ( self . buffer_width * i ) ) #NEWLINE# if ( not self . fast_mode ) : #NEWLINE# #INDENT# self . shm_attributes . write ( text = self . attributes [ i ] , start = ( self . buffer_width * i ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# for i in range ( read_start , read_end ) : #NEWLINE# #INDENT# self . shm_output . write ( text = self . data [ i ] , start = ( self . buffer_width * i ) ) #NEWLINE# if ( not self . fast_mode ) : #NEWLINE# #INDENT# self . shm_attributes . write ( text = self . attributes [ i ] , start = ( self . buffer_width * i ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# stats = { #NEWLINE# #INDENT# 'top_offset' : buf_info . srWindow . Top , #NEWLINE# 'default_attribute' : buf_info . wAttributes , #NEWLINE# 'cursor_x' : curs_col , #NEWLINE# 'cursor_y' : curs_line , #NEWLINE# 'is_alive' : 1 , #NEWLINE# #UNINDENT# } #NEWLINE# self . shm_stats . write ( stats ) #NEWLINE# self . top = buf_info . srWindow . Top #NEWLINE# self . cursor_line = curs_line #NEWLINE# if ( curs_line > ( buf_info . dwSize . Y - 200 ) ) : #NEWLINE# #INDENT# self . reset_console ( buf_info ) #NEWLINE# #UNINDENT# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# self . screen_redraw_ct += 1 #NEWLINE# self . mem_redraw_ct += 1 #NEWLINE# return None