Browse Source

Parser improvements

Current issues:
* Posts that are longer than the screen
* Posts that are exactly as long as the screen somehow
Petra Lamborn 4 years ago
parent
commit
8b5a21844a
1 changed files with 8 additions and 4 deletions
  1. 8
    4
      fedicurses.py

+ 8
- 4
fedicurses.py View File

@@ -35,7 +35,7 @@ def typeset(text, win, attr, colour):
35 35
         if cx == mx:
36 36
             if cy == my:
37 37
                 raise curses.error("Out of space")
38
-        rem = (mx - cx) + 1
38
+        rem = (mx - cx) + 0
39 39
         nsp = text.find(' ', position)
40 40
         if (strlen - position <= rem):
41 41
             win.addnstr(text[position:], rem,
@@ -46,7 +46,8 @@ def typeset(text, win, attr, colour):
46 46
                 win.addnstr(text[position:], rem, attr |
47 47
                             curses.color_pair(colour))
48 48
                 position = position + rem
49
-            newLine(win)
49
+            else:
50
+                newLine(win)
50 51
         else:
51 52
             win.addnstr(text[position:], nsp - position,
52 53
                         attr | curses.color_pair(colour))
@@ -65,7 +66,8 @@ def printPost(win, post, parser):
65 66
     typeset(":", win, 0, 0)
66 67
     newLine(win)
67 68
     if (post["spoiler_text"] != ""):
68
-        win.addstr(post["spoiler_text"], curses.A_UNDERLINE)
69
+        # win.addstr(post["spoiler_text"], curses.A_UNDERLINE)
70
+        typeset(post["spoiler_text"], win, curses.A_UNDERLINE, 0)
69 71
         newLine(win)
70 72
     parser.feed(post["content"])
71 73
     if parser.openp:
@@ -77,7 +79,9 @@ def printPost(win, post, parser):
77 79
                                              "%Y-%m-%d %H:%M:%S"))
78 80
     cy, cx = win.getyx()
79 81
     my, mx = win.getmaxyx()
80
-    win.addstr(cy, mx - len(botstring), botstring, curses.A_UNDERLINE)
82
+    # win.addstr(cy, mx - len(botstring), botstring, curses.A_UNDERLINE)
83
+    win.move(cy, mx - len(botstring))
84
+    typeset(botstring, win, curses.A_UNDERLINE, 0)
81 85
 
82 86
     newLine(win, 1)
83 87