It isn't hard to do word-wrapping in Inform. Try adapting the
following:
!-----------------------------------------------------------------------
! Word wrapping routine
! Gareth Rees, October 1995
!-----------------------------------------------------------------------
Constant MAX_STRING_LENGTH 1000; ! maximum length of string to wrap + 2
Array sb -> MAX_STRING_LENGTH; ! buffer to hold the printed string
[ WordWrap
text ! packed address of text to print
len ! length of text in characters
from ! first character not printed
width ! width of screen in characters
bp ! break point in string
start ! where to start printing from
n ! number of characters to print
flag; ! zero if this is the first line being printed, 1 otherwise
! I need to do some messing about with the string, but it starts
! out in encoded form, so I decode it to the string buffer:
@output_stream 3 sb;
print (string) text;
@output_stream -3;
! Set up parameters (recall that the first two bytes of the array
! `sb' hold the length).
width = 0->33;
len = sb-->0 + 2;
from = 2;
if (len > MAX_STRING_LENGTH) "** Error: string was too long **";
while (from < len) {
if (flag == 0) flag = 1;
else { new_line; }
! See if I can print the rest of the text on one line
bp = from + width;
if (bp >= len) {
bp = len;
jump FoundBreakPoint;
}
! find the best breakpoint, if any
for (: bp >= from: bp--)
if (sb->bp == ' ')
jump FoundBreakPoint;
! no breakpoint found, so split in middle of word
bp = from + width;
! print the text from `from' to the breakpoint
.FoundBreakPoint;
start = sb + from;
n = bp - from;
@print_table start n 1;
! skip any whitespace
from = bp;
while (sb->from == ' ') from ++;
}
];
-- Gareth Rees