@@ -53,20 +53,21 @@ def _schedule_refresh(self, when='now'): |
53 | 53 | if when == 'now': |
54 | 54 | self.request_refresh() |
55 | 55 | 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)) |
57 | 58 |
|
58 | 59 | def _request_reload(self, files_modified=('?',)): |
59 | 60 | e = bpythonevents.ReloadEvent() |
60 | 61 | e.files_modified = files_modified |
61 | 62 | 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') |
63 | 64 |
|
64 | 65 | def request_undo(self, n=1): |
65 | 66 | self.requested_events.append(bpythonevents.UndoEvent(n=n)) |
66 | 67 |
|
67 | | - def my_print(self, msg): |
| 68 | + def out(self, msg): |
68 | 69 | if hasattr(self, 'orig_stdout'): |
69 | | - self.orig_stdout.write((msg+'\n').encode('utf8')) |
| 70 | + self.orig_stdout.write((msg + '\n').encode('utf8')) |
70 | 71 | self.orig_stdout.flush() |
71 | 72 | else: |
72 | 73 | print(msg) |
@@ -75,24 +76,27 @@ def on_suspend(self): |
75 | 76 | pass |
76 | 77 |
|
77 | 78 | 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') |
79 | 80 |
|
80 | 81 | def print_output(self): |
81 | 82 | 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') |
90 | 94 | 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') |
92 | 96 | logger.debug('line:') |
93 | 97 | 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)) |
96 | 100 | return max(len(arr) - self.height, 0) |
97 | 101 |
|
98 | 102 | def get_input(self): |
|