diff options
-rw-r--r-- | ag_render.f90 | 6 | ||||
-rw-r--r-- | layout.f90 | 14 | ||||
-rw-r--r-- | render.f90 | 31 |
3 files changed, 42 insertions, 9 deletions
diff --git a/ag_render.f90 b/ag_render.f90 index bddec84..68cd0d8 100644 --- a/ag_render.f90 +++ b/ag_render.f90 @@ -630,7 +630,7 @@ contains ag_text_width = 0 end if - ag_text_width = ag_text_width + self%left_border + self%right_border + !ag_text_width = ag_text_width + self%left_border + self%right_border if(present(text_type)) then if(text_type == proportional_type_list_item) then @@ -769,7 +769,7 @@ contains text_width = ag_link_width(self, trim(text)) ! Need to remove indents, borders, etc. - text_width = text_width - self%left_border - self%right_border + !text_width = text_width - self%left_border - self%right_border call line(self%left_border, self%y + 7*self%font_size/8, & self%left_border + text_width, self%y + 7*self%font_size/8) @@ -803,7 +803,7 @@ contains ag_preformatted_width = 0 end if - ag_preformatted_width = ag_preformatted_width + self%left_border + self%right_border + !ag_preformatted_width = ag_preformatted_width + self%left_border + self%right_border end function ag_preformatted_width @@ -55,8 +55,16 @@ contains call rendering_engine%prepare_for_layout() do while(laying_out) - if(walker%line_type == line_type_text .and. .not. associated(walker%breaks)) then - walker%breaks => calculate_wrapping(rendering_engine, walker%text) + if(.not. associated(walker%breaks)) then + select case (walker%line_type) + + case (line_type_text) + walker%breaks => calculate_wrapping(rendering_engine, walker%text) + + case (line_type_preformatted) + walker%breaks => calculate_stop(rendering_engine, walker%text) + + end select end if select case (walker%line_type) @@ -65,7 +73,7 @@ contains call render_proportional(rendering_engine, walker%text, walker%breaks) case (line_type_preformatted) - call render_preformatted(rendering_engine, walker%text) + call render_preformatted(rendering_engine, walker%text, walker%breaks(1)) case (line_type_link) call render_link(rendering_engine, walker%text) @@ -377,7 +377,23 @@ contains end if end function get_start_position_and_type + + function calculate_stop(r, text) result(breaks) + implicit none + + class(renderer)::r + character(*), intent(in)::text + integer, dimension(:), pointer::breaks + allocate(breaks(1)) + + breaks(1) = len_trim(text) + do while(r%preformatted_width(text(1:breaks(1))) > r%max_width) + breaks(1) = breaks(1) - 1 + end do + + end function calculate_stop + function calculate_wrapping(r, text) result(breaks) implicit none @@ -515,16 +531,25 @@ contains end subroutine render_proportional - subroutine render_preformatted(r, text) + subroutine render_preformatted(r, text, stoppoint) implicit none class(renderer)::r character(*)::text + integer, intent(in), optional::stoppoint + + integer::i + + if(present(stoppoint)) then + i = stoppoint + else + i = len_trim(text) + end if if(r%is_preformatted_visible(text)) then - call r%draw_preformatted(text) + call r%draw_preformatted(text(1:i)) end if - r%y = r%y + r%preformatted_height(text) + r%y = r%y + r%preformatted_height(text(1:i)) end subroutine render_preformatted |