From a4cabd93063e867acdf002c8590fe6da42865b60 Mon Sep 17 00:00:00 2001 From: Griatch Date: Mon, 16 Aug 2021 21:10:44 +0200 Subject: [PATCH] Make EvTable.add_row forward row-options correctly. Resolve #2389. --- evennia/utils/evtable.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/evennia/utils/evtable.py b/evennia/utils/evtable.py index 399e9c0133..6a7420569e 100644 --- a/evennia/utils/evtable.py +++ b/evennia/utils/evtable.py @@ -308,7 +308,7 @@ def fill(text, width=_DEFAULT_WIDTH, **kwargs): # EvCell class (see further down for the EvTable itself) -class EvCell(object): +class EvCell: """ Holds a single data cell for the table. A cell has a certain width and height and contains one or more lines of data. It can shrink @@ -976,14 +976,17 @@ class EvColumn(object): Available keywods as per `EvCell.__init__`. """ + # column-level options override those in kwargs + options = {**kwargs, **self.options} + ypos = kwargs.get("ypos", None) if ypos is None or ypos > len(self.column): # add to the end - self.column.extend([EvCell(data, **self.options) for data in args]) + self.column.extend([EvCell(data, **options) for data in args]) else: # insert cells before given index ypos = min(len(self.column) - 1, max(0, int(ypos))) - new_cells = [EvCell(data, **self.options) for data in args] + new_cells = [EvCell(data, **options) for data in args] self.column = self.column[:ypos] + new_cells + self.column[ypos:] # self._balance(**kwargs) @@ -1010,6 +1013,7 @@ class EvColumn(object): Keywords as per `EvCell.__init__`. """ + # column-level options take precedence here kwargs.update(self.options) self.column[index].reformat(**kwargs)