From 2e87199d7b27f8e2ca03ccbf13cfa01fc23d2865 Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Thu, 18 Jun 2020 20:05:37 -0400 Subject: Improved line wrapping calcs to search for break from beginning of string. Fixed unnecessary connection error when reporting unsupported protocol by adding a protocol fail status. --- render.f90 | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'render.f90') diff --git a/render.f90 b/render.f90 index b37eb50..54f50e4 100644 --- a/render.f90 +++ b/render.f90 @@ -296,7 +296,7 @@ contains integer, intent(in)::startpos integer, intent(in)::proportional_type integer::endpos - integer::my_start + integer::my_start, last_end integer::w my_start = startpos @@ -306,15 +306,25 @@ contains endpos = len_trim(text) w = width_of_line(r, text, my_start, endpos, proportional_type) - do while(w > r%max_width) - - endpos = endpos - 1 - do while(text(endpos:endpos) /= ' ' .and. text(endpos:endpos) /= '-' .and. endpos > my_start) - endpos = endpos - 1 + if(w > r%max_width) then + + w = 0 + endpos = startpos+1 + do while(w <= r%max_width) + + last_end = endpos + endpos = endpos + 1 + do while(text(endpos:endpos) /= ' ' .and. text(endpos:endpos) /= '-') + endpos = endpos + 1 + end do + + w = width_of_line(r, text, my_start, endpos, proportional_type) + end do - w = width_of_line(r, text, my_start, endpos, proportional_type) - end do + endpos = last_end + + end if end function wrap_line -- cgit v1.2.3