a patch for issue #73

the problem is that during the computation of the lines, the
cursor isn't wrapping to the next line if the last character
would render "into" the edge of the box. adding a trailing
space to any incoming strings forces the line to wrap.

you can aggravate this condition by typing the following
sentence into the shell:

this is a test of a message that is too long a message

when it fails, it renders

this is a test of a messag
e that is too long a messag

adding the trailing space causes it to render as

this is a test of a messag
e that is too long a messa
ge

which is the desired behavior
This commit is contained in:
bunnie 2021-08-24 17:58:39 +08:00
parent 98afa19264
commit ebf0a02345

View file

@ -203,6 +203,9 @@ fn xmain() -> ! {
blitstr::xor_char
};
use std::fmt::Write;
write!(tv.text, " ").unwrap(); // appending a trailing space so as to "fix" issue #73
// first compute the bounding box, if it isn't computed
if tv.bounds_computed.is_none() {
match tv.bounds_hint {
@ -466,7 +469,6 @@ fn xmain() -> ! {
Some(r) => r,
_ => continue, // don't draw anything if somehow this doesn't fit in the creen.
};
let mut ref_cursor = blitstr::Cursor::from_top_left_of(cr.into());
if debugtv {
log::trace!(