#NEWLINE# def term_width( ) : #NEWLINE# #INDENT# "\n    Return the column width of the terminal, or None if it can't be determined.\n\n    " #NEWLINE# if ( fcntl and termios ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# winsize = fcntl . ioctl ( 0 , termios . TIOCGWINSZ , '    ' ) #NEWLINE# ( _ , width ) = struct . unpack ( 'hh' , winsize ) #NEWLINE# return width #NEWLINE# #UNINDENT# except IOError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( windll and create_string_buffer ) : #NEWLINE# #INDENT# ( stderr_handle , struct_size ) = ( ( - 12 ) , 22 ) #NEWLINE# handle = windll . kernel32 . GetStdHandle ( stderr_handle ) #NEWLINE# csbi = create_string_buffer ( struct_size ) #NEWLINE# res = windll . kernel32 . GetConsoleScreenBufferInfo ( handle , handle ) #NEWLINE# if res : #NEWLINE# #INDENT# ( _ , _ , _ , _ , _ , left , _ , right , _ , _ , _ ) = struct . unpack ( 'hhhhHhhhhhh' , csbi . raw ) #NEWLINE# return ( ( right - left ) + 1 )