|
@@ -10,28 +10,38 @@ def initColours():
|
10
|
10
|
|
11
|
11
|
def newLine(ncwin, lines=1):
|
12
|
12
|
cy, cx = ncwin.getyx()
|
13
|
|
- ncwin.move(cy + lines, 0)
|
|
13
|
+ # my, mx = ncwin.getmaxyx()
|
|
14
|
+ try:
|
|
15
|
+ ncwin.move(cy + lines, 0)
|
|
16
|
+ except curses.error:
|
|
17
|
+ pass
|
14
|
18
|
|
15
|
19
|
def bump(win):
|
16
|
20
|
my, mx = win.getmaxyx()
|
17
|
21
|
cy, cx = win.getyx()
|
18
|
|
- if cx != mx:
|
19
|
|
- win.move(cy, cx + 1)
|
20
|
|
-
|
|
22
|
+ if cx < mx and cx != 0:
|
|
23
|
+ try:
|
|
24
|
+ win.move(cy, cx + 1)
|
|
25
|
+ except curses.error:
|
|
26
|
+ pass
|
21
|
27
|
|
22
|
28
|
def typeset(text, win, attr, colour):
|
23
|
29
|
my, mx = win.getmaxyx()
|
24
|
30
|
line = 0
|
25
|
31
|
position = 0
|
26
|
32
|
strlen = len(text)
|
27
|
|
- while position < (strlen - 1):
|
|
33
|
+ while position < (strlen):
|
28
|
34
|
cy, cx = win.getyx()
|
29
|
35
|
if cx == mx:
|
30
|
36
|
if cy == my:
|
31
|
37
|
raise curses.error("Out of space")
|
32
|
38
|
rem = (mx - cx) + 1
|
33
|
39
|
nsp = text.find(' ', position)
|
34
|
|
- if nsp == -1 or nsp - position > rem:
|
|
40
|
+ if (strlen - position <= rem):
|
|
41
|
+ win.addnstr(text[position:], rem,
|
|
42
|
+ attr | curses.color_pair(colour))
|
|
43
|
+ position = strlen
|
|
44
|
+ elif (nsp == -1 or nsp - position > rem): # and not strlen - position <= rem:
|
35
|
45
|
if cx == 0:
|
36
|
46
|
win.addnstr(text[position:], rem, attr |
|
37
|
47
|
curses.color_pair(colour))
|
|
@@ -40,15 +50,19 @@ def typeset(text, win, attr, colour):
|
40
|
50
|
else:
|
41
|
51
|
win.addnstr(text[position:], nsp - position,
|
42
|
52
|
attr | curses.color_pair(colour))
|
43
|
|
- position = nsp + 1
|
|
53
|
+ position = max(nsp, 0) + 1
|
44
|
54
|
bump(win)
|
45
|
55
|
|
46
|
56
|
def printPost(win, post, parser):
|
47
|
|
- win.addstr(post["account"]["acct"], curses.A_BOLD)
|
|
57
|
+ # win.addstr(post["account"]["acct"], curses.A_BOLD)
|
|
58
|
+ typeset(post["account"]["acct"], win, curses.A_BOLD, 0)
|
48
|
59
|
if (post["reblog"] is not None):
|
49
|
|
- win.addstr(" boosted ")
|
50
|
|
- win.addstr(post["reblog"]["account"]["acct"], curses.A_BOLD)
|
51
|
|
- win.addstr(":")
|
|
60
|
+ # win.addstr(" boosted ")
|
|
61
|
+ typeset(" boosted ", win, 0, 0)
|
|
62
|
+ # win.addstr(post["reblog"]["account"]["acct"], curses.A_BOLD)
|
|
63
|
+ typeset(post["reblog"]["account"]["acct"], win, curses.A_BOLD, 0)
|
|
64
|
+ # win.addstr(":")
|
|
65
|
+ typeset(":", win, 0, 0)
|
52
|
66
|
newLine(win)
|
53
|
67
|
if (post["spoiler_text"] != ""):
|
54
|
68
|
win.addstr(post["spoiler_text"], curses.A_UNDERLINE)
|
|
@@ -115,7 +129,7 @@ class PostParser(HTMLParser):
|
115
|
129
|
|
116
|
130
|
def handle_endtag(self, tag):
|
117
|
131
|
if tag == 'p':
|
118
|
|
- newLine(self.win)
|
|
132
|
+ newLine(self.win, 2)
|
119
|
133
|
self.openp = False
|
120
|
134
|
elif tag == 'strong' or tag == 'b':
|
121
|
135
|
self.curatt = self.curatt ^ curses.A_REVERSE
|