@@ -53,20 +53,21 @@ def _schedule_refresh(self, when='now'):
5353 if when == 'now' :
5454 self .request_refresh ()
5555 else :
56- self .my_print ('please refresh in ' + str (round (when - time .time (), 1 ))+ ' seconds' )
56+ dt = round (when - time .time (), 1 )
57+ self .out ('please refresh in {} seconds' .format (dt ))
5758
5859 def _request_reload (self , files_modified = ('?' ,)):
5960 e = bpythonevents .ReloadEvent ()
6061 e .files_modified = files_modified
6162 self .requested_events .append (e )
62- self .my_print ('please hit enter to trigger a refresh' )
63+ self .out ('please hit enter to trigger a refresh' )
6364
6465 def request_undo (self , n = 1 ):
6566 self .requested_events .append (bpythonevents .UndoEvent (n = n ))
6667
67- def my_print (self , msg ):
68+ def out (self , msg ):
6869 if hasattr (self , 'orig_stdout' ):
69- self .orig_stdout .write ((msg + '\n ' ).encode ('utf8' ))
70+ self .orig_stdout .write ((msg + '\n ' ).encode ('utf8' ))
7071 self .orig_stdout .flush ()
7172 else :
7273 print (msg )
@@ -75,24 +76,27 @@ def on_suspend(self):
7576 pass
7677
7778 def after_suspend (self ):
78- self .my_print ('please hit enter to trigger a refresh' )
79+ self .out ('please hit enter to trigger a refresh' )
7980
8081 def print_output (self ):
8182 arr , cpos = self .paint ()
82- arr [cpos [0 ]:cpos [0 ]+ 1 , cpos [1 ]:cpos [1 ]+ 1 ] = ['~' ]
83-
84- self .my_print ('X' * (self .width + 8 ))
85- self .my_print (' enter -> "/", rewind -> "\\ ", ' .center (self .width + 8 , 'X' ))
86- self .my_print (' reload -> "|", pastebin -> "$", ' .center (self .width + 8 , 'X' ))
87- self .my_print (' "~" is the cursor ' .center (self .width + 8 , 'X' ))
88- self .my_print ('X' * (self .width + 8 ))
89- self .my_print ('X``' + ('`' * (self .width + 2 ))+ '``X' )
83+ arr [cpos [0 ]:cpos [0 ] + 1 , cpos [1 ]:cpos [1 ] + 1 ] = ['~' ]
84+
85+ def print_padded (s ):
86+ return self .out (s .center (self .width + 8 , 'X' ))
87+
88+ print_padded ('' )
89+ print_padded (' enter -> "/", rewind -> "\\ ", ' )
90+ print_padded (' reload -> "|", pastebin -> "$", ' )
91+ print_padded (' "~" is the cursor ' )
92+ print_padded ('' )
93+ self .out ('X``' + ('`' * (self .width + 2 )) + '``X' )
9094 for line in arr :
91- self .my_print ('X```' + unicode (line .ljust (self .width ))+ '```X' )
95+ self .out ('X```' + unicode (line .ljust (self .width )) + '```X' )
9296 logger .debug ('line:' )
9397 logger .debug (repr (line ))
94- self .my_print ('X``' + ('`' * (self .width + 2 ))+ '``X' )
95- self .my_print ('X' * (self .width + 8 ))
98+ self .out ('X``' + ('`' * (self .width + 2 )) + '``X' )
99+ self .out ('X' * (self .width + 8 ))
96100 return max (len (arr ) - self .height , 0 )
97101
98102 def get_input (self ):
0 commit comments