7 #include "wvwordwrap.h"
9 WvWordWrapEncoder::WvWordWrapEncoder(
int _maxwidth) :
12 line =
new char[maxwidth];
17 WvWordWrapEncoder::~WvWordWrapEncoder()
26 curindex = wordindex = 0;
35 while (inbuf.
used() != 0)
37 int ch = inbuf.
getch();
52 if (width <= maxwidth)
53 line[curindex++] = ch;
59 width = (width + 8) & ~7;
60 if (width <= maxwidth)
61 line[curindex++] = ch;
65 if (width >= maxwidth)
70 curindex = wordindex = 0;
73 else if (wordindex == 0)
82 curindex -= wordindex;
83 memmove(line, line + wordindex, curindex);
95 line[curindex++] = ch;
106 void WvWordWrapEncoder::flushline(
WvBuf &outbuf)
108 outbuf.put(line, curindex);
109 curindex = wordindex = 0;