Commit c80fb8c6 authored by Lysander Trischler's avatar Lysander Trischler

Show complete conversation tree when replying

parent f9031e20
......@@ -289,7 +289,17 @@ class TwtsListBox(widgets.VimListBox, TwtFormatter):
def open_reply_twt_form(self):
frame.body.push_widget(TwtForm(self._manager, self.selected_twt, [self.body[self.focus_position]]))
def conversation_length(twt):
l = 1 # one for the current twt
for reply in twt.replies:
l += conversation_length(reply)
return l
selected_twt = self.selected_twt
end_pos = self.focus_position + conversation_length(selected_twt)
frame.body.push_widget(TwtForm(self._manager, selected_twt,
self.body[self.focus_position:end_pos]))
class URLListBox(widgets.VimListBox):
......@@ -448,7 +458,7 @@ class TwtForm(urwid.ListBox):
preview = urwid.Button("Preview Twt", on_press=self.preview_twt)
publish = urwid.Button("Publish Twt", on_press=self.publish_twt)
cancel = urwid.Button("Cancel", on_press=lambda *_: frame.body.pop_widget())
super().__init__(list(map(widgets.Unselectable, rendered_conversation)) + [
super().__init__(rendered_conversation + [
urwid.LineBox(self._text_edit, title="Reply" if original_twt else "New Twt", title_align="left"),
urwid.LineBox(self._created_at_edit, title="Created at", title_align="left"),
urwid.Columns([urwid.Text(""),
......@@ -460,6 +470,13 @@ class TwtForm(urwid.ListBox):
self._original_twt = original_twt
self._rendered_conversation = rendered_conversation
# Focus the text edit, which follows directly the conversation. This
# way, the user can immediately start typing. This scrolls down in the
# context of rendered twts in the conversation. Unfortunately, it
# doesn't look like it's possible to tell urwid, that the buttons down
# below should also be visible. :-(
self.focus_position = len(rendered_conversation)
def _collect_authors(self, twt):
authors = []
......@@ -519,6 +536,10 @@ class PreviewForm(urwid.ListBox, TwtFormatter):
(len(back.label) + 4, back)],
dividechars=2)])
# Focus the back button which is after the rendered conversation and
# the preview.
self.focus_position = len(rendered_conversation) + 1
show_subjects = False
fold_subjects = True
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment