fdoc

subroutinefold_linepureprivate

pure subroutine fold_line(line, b)

Fold a line in Fypp's default way, at a blank near the end of the line if there is one.

Arguments

NameTypeIntentAttributesDescription
linecharacter(len=*)in

the line

btype(buffer_t)inout

where it goes

Calls

Source

Show the code
pure subroutine fold_line(line, b)
    character(len=*), intent(in) :: line    !! the line
    type(buffer_t), intent(inout) :: b      !! where it goes
    character(len=:), allocatable :: prefix
    integer :: n, indent, room, room_middle, first, last

    n = len(line)
    indent = skip_blanks(line, 1) - 1
    if (n <= MAX_LINE) then
        call add(b, line)
        return
    end if
    if (line(indent + 1:indent + 1) == '!') then
        call add(b, line)
        return
    end if
    prefix = repeat(' ', indent + FOLD_INDENT)//'&'
    room = MAX_LINE - len(prefix)
    room_middle = room - 1
    first = 0
    last = fold_position(line, first, MAX_LINE - 1)
    call add(b, line(first + 1:last)//'&')
    do while (last < n - room)
        first = last
        last = fold_position(line, first, first + room_middle)
        call add(b, NL//prefix//line(first + 1:last)//'&')
    end do
    call add(b, NL//prefix//line(last + 1:))
end subroutine fold_line

Graphs

Calls

Called by