text with the statements at changed (byte ranges, in order) laid out again, each on its own
at the column where it starts. text is formatted apart from those statements, and they do
not depend on the lines around them (see stands_alone), so this gives what formatting the
whole text again would, in a fraction of the time.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | text |
the text, after lines were split |
||
| integer, | intent(in) | :: | changed(:,:) |
byte ranges of the statements to lay out |
||
| type(format_options_t), | intent(in) | :: | opts |
the formatting options |
function relayout(text, changed, opts) result(out) !! `text` with the statements at `changed` (byte ranges, in order) laid out again, each on its own !! at the column where it starts. `text` is formatted apart from those statements, and they do !! not depend on the lines around them (see [[stands_alone]]), so this gives what formatting the !! whole text again would, in a fraction of the time. character(len=*), intent(in) :: text !! the text, after lines were split integer, intent(in) :: changed(:, :) !! byte ranges of the statements to lay out type(format_options_t), intent(in) :: opts !! the formatting options character(len=:), allocatable :: out type(format_options_t) :: alone type(diagnostic_t), allocatable :: unused(:) type(string_builder_t) :: buf character(len=:), allocatable :: piece integer :: j, next alone = opts next = 1 do j = 1, size(changed, 2) associate (a => changed(1, j), b => changed(2, j)) call buf%append(text(next:a - 1)) alone%base_indent = verify(text(a:b)//'x', ' ') - 1 ! its indentation call format_pass(text(a:b), alone, piece, unused) call buf%append(piece) next = b + 1 end associate end do call buf%append(text(next:)) out = buf%get() end function relayout