diff options
Diffstat (limited to 'alot')
-rw-r--r-- | alot/buffers/thread.py | 19 | ||||
-rw-r--r-- | alot/commands/search.py | 2 | ||||
-rw-r--r-- | alot/ui.py | 3 |
3 files changed, 18 insertions, 6 deletions
diff --git a/alot/buffers/thread.py b/alot/buffers/thread.py index 1e751f1a..47b7f9d0 100644 --- a/alot/buffers/thread.py +++ b/alot/buffers/thread.py @@ -23,6 +23,9 @@ class ThreadBuffer(Buffer): modename = 'thread' + ui = None + thread = None + # list of the widgets containing the message body # indexed by its depth-first position in the thread tree _msg_widgets = None @@ -34,11 +37,12 @@ class ThreadBuffer(Buffer): # WidgetPlaceholder that wraps currently displayed message _cur_msg_holder = None - def __init__(self, thread): + def __init__(self, ui, thread): """ :param thread: thread to display :type thread: :class:`~alot.db.Thread` """ + self.ui = ui self.thread = thread self._indent_width = settings.get('thread_indent_replies') @@ -121,10 +125,15 @@ class ThreadBuffer(Buffer): self._msg_widgets.append(msg_wgt) list_walker.append(wgt) - # the weight given to the thread-tree widget is proportional to the number of - # messages in it plus 1 (for surrounding decoration), up to the limit of - # 49 messages, when it is equal to the message body widget - tree_weight = min(0.01 * (len(self._msg_widgets) + 1), 0.5) + # approximate weight for one terminal line + # substract 3 for decoration and panels + line_weight = 1.0 / max(self.ui.get_cols_rows()[1] - 3, 1) + + # the default weight given to the thread-tree widget is proportional to + # the number of messages in it plus 2 (for surrounding decoration) - + # scaled to approximately one line per message - up to maximum weight of + # half the screen + tree_weight = min(line_weight * (len(self._msg_widgets) + 2), 0.5) self.msgtree_weight = tree_weight if len(self._msg_widgets) > 0: diff --git a/alot/commands/search.py b/alot/commands/search.py index f4e8efdc..9fe265cb 100644 --- a/alot/commands/search.py +++ b/alot/commands/search.py @@ -37,7 +37,7 @@ class OpenThreadCommand(Command): query = ui.current_buffer.querystring logging.info('open thread view for %s', self.thread) - tb = buffers.ThreadBuffer(self.thread) + tb = buffers.ThreadBuffer(ui, self.thread) ui.buffer_open(tb) tb.focus_next_matching(query) @@ -811,3 +811,6 @@ class UI: for line in history: histfile.write(line) histfile.write('\n') + + def get_cols_rows(self): + return self.mainloop.screen.get_cols_rows() |