ref: 555d5ccd00ee6906a346f63338a520c92a8e0e6f
parent: 3aa41b98d677101317487d504fefc49e433b16bf
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Aug 26 11:28:40 EDT 2017
Fix line wrapping.
--- a/irc.myr
+++ b/irc.myr
@@ -677,8 +677,8 @@
const drawtext = {cli, x0, y0, x1, y1, cvar height, margin, width, off
- var count, len
var t, dx, dy
+ var count
var x, y
t = cli.term
@@ -686,11 +686,12 @@
termdraw.clear(t, x0, y0, x1, y1)
termdraw.move(t, x0, y0)
+ dx = x1 - x0
+ dy = y1 - y0
count = 0
height = 0
+ width = dx
off = 0
- dx = x1 - x0
- dy = y1 - y0
/* nothing worth drawing... */
if dx <= c.gutter
-> void
@@ -701,25 +702,25 @@
| `Msg (m, ln):
margin = c.gutter
width = termdraw.strwidth(t, ln)
- height += width / (dx - margin)
+ height += width / (dx - margin + 1) + 1
| `Join user:
width = termdraw.strwidth(t, "#joined: ")
width += termdraw.strwidth(t, user)
- height += width / dx
+ height += width / (dx + 1) + 1
| `Part user:
width = termdraw.strwidth(t, "#parted: ")
width += termdraw.strwidth(t, user)
- height += width / dx
+ height += width / (dx + 1) + 1
| `Status msg:
width = termdraw.strwidth(t, "! ")
width += termdraw.strwidth(t, msg)
- height += width / dx
+ height += width / (dx + 1) + 1
;;
count++
if height == dy
break
elif height > dy
- off = dx * (dy - 1) + len % dx
+ off = (dx - margin)*(height - dy - 1) + width % dx
break
;;
;;
--
⑨