From 93eba9d7a98631b445d7ca745b1edb5da6beb1f4 Mon Sep 17 00:00:00 2001 From: Griatch Date: Fri, 31 Jan 2014 00:27:54 +0100 Subject: [PATCH] Added Cell ability to replace data in-situ. --- src/utils/mudtable.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/utils/mudtable.py b/src/utils/mudtable.py index 2c80500289..aff70f9406 100644 --- a/src/utils/mudtable.py +++ b/src/utils/mudtable.py @@ -315,6 +315,18 @@ class Cell(object): "Get width of cell, including padding" return len(self.formatted[0]) if self.formatted else 0 + def replace_data(self, data, **kwargs): + """ + Replace cell data. This causes a full reformat of the cell. + + kwargs - like when creating the cell anew. + """ + self.data = self._split_lines(unicode(data)) + #self.data = self._split_lines(ANSIString(unicode(data))) + self.raw_width = max(len(line) for line in self.data) + self.raw_height = len(self.data) + self.reformat(**kwargs) + def reformat(self, **kwargs): """ Reformat the Cell with new options