@@ -0,0 +1,2313 @@
+#!/usr/bin/python%0A#%0A# This file is part of lava-hacks.  lava-hacks is free software: you can%0A# redistribute it and/or modify it under the terms of the GNU General Public%0A# License as published by the Free Software Foundation, version 2.%0A#%0A# This program is distributed in the hope that it will be useful, but WITHOUT%0A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS%0A# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more%0A# details.%0A#%0A# You should have received a copy of the GNU General Public License along with%0A# this program; if not, write to the Free Software Foundation, Inc., 51%0A# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.%0A#%0A# Copyright Anders Roxell 2015%0A%0Adef get_sub_str(text, from_pos, num_chars, break_chars):%0A    sub_str = text%5Bfrom_pos:from_pos+num_chars%5D%0A    for index, ch in enumerate(sub_str):%0A        if ch in break_chars:%0A            return (sub_str%5B:index%5D, from_pos+index+1)%0A    return (sub_str, from_pos+len(sub_str))%0A%0A%0Aclass TextBlock(object):%0A    def __init__(self, text=%22%22, width=0):%0A        self.text = str(text)%0A        self.width = width%0A        self.block = list()%0A%0A%0A    def set_width(self, width, reflow=True):%0A        self.width = width%0A%0A        if reflow: self.reflow()%0A%0A%0A    def set_text(self, text, reflow=True):%0A        self.text = str(text)%0A%0A        if reflow: self.reflow()%0A%0A%0A    def append_text(self, new_text, reflow=True):%0A        self.text += str(text)%0A%0A        if reflow: self.reflow()%0A%0A%0A    def get_block(self, start_line, num_lines):%0A        block_len = len(self.block)%0A        if start_line %3C 0:%0A            start_line = block_len-start_line-num_lines%0A%0A        if start_line+num_lines %3E block_len:%0A            num_lines = block_len-start_line%0A        return self.block%5Bstart_line:start_line+num_lines%5D%0A%0A%0A    def reflow(self, width=0):%0A        if not self.width:%0A            raise Exception(%22Cannot reflow to windows of width %25d%22 %25 self.width)%0A%0A        del self.block%5B:%5D%0A        self.width = width or self.width%0A%0A        text_len = len(self.text)%0A        cur_pos = 0%0A%0A        while cur_pos %3C text_len:%0A            cur_line, next_pos = get_sub_str(self.text, cur_pos, self.width, ('%5Cn',))%0A            self.block.append(cur_line)%0A            cur_pos = next_pos%0A%0A%0A# vim: set sw=4 sts=4 et fileencoding=utf-8 :%0A

Revert "WIP remove lib/text_output.py"