!>
attr_mode(3f) - [M_attr] select processing mode for output from attr(3f)
(LICENSE:MIT)
 subroutine attr_mode(manner)
    character(len=*),intent(in) :: manner
Turn off the generation of strings associated with the HTML keywords
in the string generated by the attr(3f) function, or display the
text in raw mode as it was passed to attr(3f) or return to ANSI
escape control sequence generation.
MANNER  The current manners or modes supported via the attr_mode(3f)
         procedure are
     plain          suppress the output associated with keywords
     color(default) commonly supported escape sequences
     raw            echo the input to attr(3f) as its output
     reload         restore original keyword meanings deleted or
                    replaced by calls to attr_update(3f).
Sample program
 program demo_attr_mode
 use M_attr, only : attr, attr_mode
 implicit none
 character(len=:),allocatable :: lines(:)
 character(len=:),allocatable :: outlines(:)
 integer :: i
    lines=[character(len=110):: &
    &'<M><y>',&
    &'<M><y>  Suffice it to say that black and white are also colors',&
    &'<M><y>  for their simultaneous contrast is as striking as that ',&
    &'<M><y>  of green and red, for instance. &
    & --- <y><bo>Vincent van Gogh</bo></y>',&
    &' ']
    outlines=attr(lines,chars=57)
    write(*,'(a)')(trim(outlines(i)),i=1,size(outlines))
    call attr_mode(manner='plain') ! write as plain text
    write(*,'(a)')attr(lines)
    call attr_mode(manner='raw')   ! write as-is
    write(*,'(a)')attr(lines)
    call attr_mode(manner='ansi')  ! return to default mode
 end program demo_attr_mode
John S. Urban, 2021
MIT
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | manner | 
subroutine attr_mode(manner) character(len=*),intent(in) :: manner integer :: i if(.not.allocated(mode))then ! set substitution mode mode='color' call vt102() endif select case(manner) case('vt102','ANSI','ansi','color','COLOR') mode='color' case('reload','default','defaults','') call vt102() mode='color' case('raw') mode='raw' case('dump') ! dump dictionary for debugging if(allocated(keywords))then if(size(keywords).gt.0)then write(stderr,'(*(a,t30,a))')'KEYWORD','VALUE' write(stderr,'(*(a,t30,2("[",a,"]"),/))')(trim(keywords(i)),values(i),mono_values(i),i=1,size(keywords)) endif endif case('dummy','plain','text') mode='plain' case default write(*,*)'unknown manner. Try color|raw|plain' mode='color' end select end subroutine attr_mode