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