read status, eyecandy
This commit is contained in:
parent
0e590eefed
commit
edeeb793ff
15
hn.py
15
hn.py
@ -1,10 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
#TODO: make sure things dont explode no matter what terminal size
|
|
||||||
# x prevent linebreaks in a single story
|
|
||||||
# x only load as many stories as fit
|
|
||||||
# -> refresh on resize
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup as Soup
|
from bs4 import BeautifulSoup as Soup
|
||||||
import curses
|
import curses
|
||||||
@ -72,10 +67,16 @@ class Client:
|
|||||||
|
|
||||||
self.screen.addstr(prefix)
|
self.screen.addstr(prefix)
|
||||||
if i == self.cursor_pos:
|
if i == self.cursor_pos:
|
||||||
|
if story.read:
|
||||||
|
self.screen.addstr(title, curses.A_DIM | curses.A_UNDERLINE)
|
||||||
|
else:
|
||||||
self.screen.addstr(title, curses.A_UNDERLINE)
|
self.screen.addstr(title, curses.A_UNDERLINE)
|
||||||
self.screen.addstr(f' ({link})\n', curses.A_DIM )
|
self.screen.addstr(f' ({link})\n', curses.A_DIM )
|
||||||
detail = f' by {story.author} | {story.comments} comments | {story.votes} points\n'
|
detail = f' by {story.author} | {story.comments} comments | {story.votes} points\n'
|
||||||
self.screen.addstr(detail)
|
self.screen.addstr(detail)
|
||||||
|
else:
|
||||||
|
if story.read:
|
||||||
|
self.screen.addstr(title, curses.A_DIM)
|
||||||
else:
|
else:
|
||||||
self.screen.addstr(title)
|
self.screen.addstr(title)
|
||||||
self.screen.addstr(f' ({link})\n', curses.A_DIM )
|
self.screen.addstr(f' ({link})\n', curses.A_DIM )
|
||||||
@ -107,7 +108,11 @@ class Client:
|
|||||||
elif c == ord('c'):
|
elif c == ord('c'):
|
||||||
webbrowser.open(f'https://news.ycombinator.com/item?id={self.loadedstories[self.story_pos + self.cursor_pos].id}')
|
webbrowser.open(f'https://news.ycombinator.com/item?id={self.loadedstories[self.story_pos + self.cursor_pos].id}')
|
||||||
elif c == curses.KEY_ENTER or c == 10:
|
elif c == curses.KEY_ENTER or c == 10:
|
||||||
|
if self.loadedstories[self.story_pos + self.cursor_pos].link == 'No URL':
|
||||||
|
webbrowser.open(f'https://news.ycombinator.com/item?id={self.loadedstories[self.story_pos + self.cursor_pos].id}')
|
||||||
|
else:
|
||||||
webbrowser.open(self.loadedstories[self.story_pos + self.cursor_pos].link)
|
webbrowser.open(self.loadedstories[self.story_pos + self.cursor_pos].link)
|
||||||
|
self.loadedstories[self.story_pos + self.cursor_pos].read = True
|
||||||
elif c == curses.KEY_RESIZE:
|
elif c == curses.KEY_RESIZE:
|
||||||
curses.resize_term(*self.screen.getmaxyx())
|
curses.resize_term(*self.screen.getmaxyx())
|
||||||
self.lines, self.cols = self.screen.getmaxyx()
|
self.lines, self.cols = self.screen.getmaxyx()
|
||||||
|
Loading…
Reference in New Issue
Block a user