ihabunek / toot

toot - Mastodon CLI & TUI
GNU General Public License v3.0
1.15k stars 111 forks source link

Continuous Timeline #5

Closed vext01 closed 6 years ago

vext01 commented 7 years ago

Hi,

It would be neat if there were a flag to toot timeline which showed toots live as they came in. I suppose that would require polling, so you'd have to be careful not to overwhelm the server limits.

ihabunek commented 7 years ago

Actually I'm working on a curses-powered interface which will allow paging through the timeline. I will look into adding live updates. There is a streaming API which gives you the updates as they come in.

Xillie2006 commented 7 years ago

I love what you're doing. I was hoping curses interface cli would come. My hope is in your hands:) Also, I can see the "My timeline". Will there be a command to show "Local timeline" and "Global timeline"?

ihabunek commented 7 years ago

Sure. But so many features... so little time... :)

vext01 commented 7 years ago

Regarding curses. I've used urwid in the past, which was much less painless than curses: http://urwid.org/

I notice that that page also lists other abstractions: http://www.npcole.com/npyscreen/ https://github.com/thomasballinger/curtsies https://github.com/jonathanslenders/python-prompt-toolkit

ihabunek commented 7 years ago

@vext01 Thanks for the suggestions, I will go through them.

Since this is my first curses app, I wanted to try it out vanilla before jumping aboard the abstractions, so I could better understand how it works.

I have a basic timeline app implementation which I'd like to push out soon, but I'm away to Webcamp Ljubljana tomorrow so it may be a couple of days.

ihabunek commented 7 years ago

@vext01 or I can waste another evening hacking :) I just pushed 0.9.0 which has a rudimentary timeline app. Try running toot curses.

Would something along these lines be interesting for you?

Obviously, there's a long way to go.

vext01 commented 7 years ago

Oops! Python2.7/OpenBSD:

$ toot curses
Traceback (most recent call last):
  File "/home/edd/.local/bin/toot", line 11, in <module>
    sys.exit(main())
  File "/home/edd/.local/lib/python2.7/site-packages/toot/console.py", line 221, in main
    run_command(app, user, command_name, args)
  File "/home/edd/.local/lib/python2.7/site-packages/toot/console.py", line 200, in run_command
    return fn(app, user, parsed_args)
  File "/home/edd/.local/lib/python2.7/site-packages/toot/commands.py", line 172, in curses
    TimelineApp(generator).run()
  File "/home/edd/.local/lib/python2.7/site-packages/toot/app.py", line 40, in run
    curses.wrapper(self._wrapped_run)
  File "/usr/local/lib/python2.7/curses/wrapper.py", line 43, in wrapper
    return func(stdscr, *args, **kwds)
  File "/home/edd/.local/lib/python2.7/site-packages/toot/app.py", line 55, in _wrapped_run
    self.fetch_next()
  File "/home/edd/.local/lib/python2.7/site-packages/toot/app.py", line 112, in fetch_next
    statuses = self.status_generator.__next__()
AttributeError: 'generator' object has no attribute '__next__'
ihabunek commented 7 years ago

It's a python2 bug, did not have time to investigate. Having 2+3 support is a major pain in the butt.

ihabunek commented 7 years ago

BTW, I'm in the process of learning urwid. Seems simpler than plain curses, but still a bit archaic.

vext01 commented 7 years ago

Why not just drop python 2 support? Would save you some time I'm sure.

vext01 commented 7 years ago

Works under pyhton3.6 fine.

If the window is too small I get:

arrakis> toot curses
Traceback (most recent call last):
  File "/home/edd/.local/bin/toot", line 11, in <module>
    sys.exit(main())
  File "/home/edd/.local/lib/python3.6/site-packages/toot/console.py", line 285, in main
    run_command(app, user, command_name, args)
  File "/home/edd/.local/lib/python3.6/site-packages/toot/console.py", line 262, in run_command
    return fn(app, user, parsed_args)
  File "/home/edd/.local/lib/python3.6/site-packages/toot/commands.py", line 176, in curses
    TimelineApp(generator).run()
  File "/home/edd/.local/lib/python3.6/site-packages/toot/app.py", line 40, in run
    curses.wrapper(self._wrapped_run)
  File "/usr/local/lib/python3.6/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "/home/edd/.local/lib/python3.6/site-packages/toot/app.py", line 57, in _wrapped_run
    self.full_redraw()
  File "/home/edd/.local/lib/python3.6/site-packages/toot/app.py", line 134, in full_redraw
    self.draw_statuses(self.left)
  File "/home/edd/.local/lib/python3.6/site-packages/toot/app.py", line 181, in draw_statuses
    self.draw_status_row(window, status, offset, highlight)
  File "/home/edd/.local/lib/python3.6/site-packages/toot/app.py", line 173, in draw_status_row
    window.addstr(offset + 4, 1, '─' * (width - 2))
_curses.error: addwstr() returned ERR

I'd recommend a variable window size, and allowing 80x25, since that is standard.

ihabunek commented 6 years ago

Closing as duplicate of #28.