diff --git a/mode/consolemini.py b/mode/consolemini.py index f16e2e0..cafbd9a 100644 --- a/mode/consolemini.py +++ b/mode/consolemini.py @@ -4,6 +4,8 @@ from lex import Grammar, PatternRule from mode.python import PythonGrammar from point import Point +LIMIT = 79 + class ConsoleExec(method.Method): def _execute(self, w, **vargs): s = w.buffer.make_string() @@ -57,7 +59,21 @@ class ConsoleExec(method.Method): newlines = [' %s' % x for x in output.split('\n')] assert newlines[-1] == ' ' newlines[-1] = '' - b.insert_lines(b.get_buffer_end(), newlines, force=True) + newlines2 = [] + for line in newlines: + i = 0 + while i + LIMIT < len(line): + j = LIMIT + while j > 0 and line[i + j] != ' ': + j -= 1 + if j == 0: + newlines2.append(line[i:i + LIMIT]) + i += j + else: + newlines2.append(line[i:i + j]) + i += j + 1 + newlines2.append(line[i:]) + b.insert_lines(b.get_buffer_end(), newlines2, force=True) for w2 in b.windows: w2.goto_end()