Skip to content

Commit

Permalink
Include mentions and replied-to account in compose text
Browse files Browse the repository at this point in the history
We add a "mentions" attribute to Status. Then when composing a reply, we
fill the edit text of the compose box with the account name of status
being replied to and possibly include mentions at the bottom of the edit
text. Initial cursor position is set after replied account name.
  • Loading branch information
dlax authored and ihabunek committed Sep 18, 2019
1 parent a76f4ae commit 9623219
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion toot/tui/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ class StatusComposer(urwid.Frame):

def __init__(self, in_reply_to=None):
self.in_reply_to = in_reply_to
self.content_edit = EditBox(multiline=True, allow_tab=True)
text, edit_pos = '', None
if in_reply_to is not None:
text = f'@{in_reply_to.account} '
edit_pos = len(text)
mentions = [f'@{m["acct"]}' for m in in_reply_to.mentions]
if mentions:
text += '\n\n{}'.format(' '.join(mentions))
self.content_edit = EditBox(edit_text=text, edit_pos=edit_pos,
multiline=True, allow_tab=True)

self.cw_edit = None
self.cw_add_button = Button("Add content warning",
Expand Down
2 changes: 2 additions & 0 deletions toot/tui/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def __init__(self, data, is_mine, default_instance):
self.reblog = reblog = data.get("reblog")
self.url = reblog.get("url") if reblog else data.get("url")

self.mentions = data["mentions"]

def get_author(self):
# Show the author, not the persopn who reblogged
data = self.data["reblog"] or self.data
Expand Down

0 comments on commit 9623219

Please sign in to comment.