From 2604a599f1127d5ac384d76d5446efd1d240bfda Mon Sep 17 00:00:00 2001 From: moculus Date: Sun, 4 May 2008 17:55:08 +0000 Subject: [PATCH] console line-splitting junk --HG-- branch : pmacs2 --- mode/consolemini.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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()