summaryrefslogtreecommitdiff
path: root/alot/buffers
diff options
context:
space:
mode:
Diffstat (limited to 'alot/buffers')
-rw-r--r--alot/buffers/thread.py19
1 files changed, 14 insertions, 5 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: