Manual Reference Pages  - add_border (3m_unicode)

NAME

add_border(3f) - [M_unicode:EDITING] add border of UTF8-encoded box characters (LICENSE:MIT)

CONTENTS

Synopsis
Characteristics
Description
Options
Returns
Examples
Author
License

SYNOPSIS

syntax:

      function add_border(win,style) result(winout)

type(unicode_type)|character(len=*),intent(in) :: win(:)|win type(unicode_type)|character(len=*),intent(in),optional :: style type(unicode_type),allocatable :: winout(:)

CHARACTERISTICS

o WIN can be a scaler or vector of CHARACTER or TYPE(UNICODE_TYPE) strings.
o WINOUT elements will all have the length of the longest element of WIN

DESCRIPTION

Add a border of box characters around character or string (ie. type(unicode_type)) scalar or vector text.

OPTIONS

win input array to be changed
style
  may be "light", "bold", or "double". Default is "bold".

RETURNS

winout
  an array of strings with a box character border added

EXAMPLES

Sample Program:

   program demo_add_border
   use M_unicode, only : ut=>unicode_type, assignment(=)
   use M_unicode, only : character, add_border, trim
   implicit none
   type(ut),allocatable       :: textout(:)
   type(ut)                   :: uline
   type(ut),allocatable       :: uparagraph(:)
   character(len=*),parameter :: paragraph(*)=[character(len=10) :: &
   &’one’,&
   &’two’,&
   &’three’,&
   &’four’]

! show original text textout=paragraph call write_text()

! character array textout=add_border(paragraph) call write_text()

! ragged string array uparagraph=paragraph uparagraph=trim(uparagraph) textout=add_border(uparagraph) call write_text()

! add another border and specify style textout=add_border(textout,style=’DOUBLE’) call write_text()

! scalar character textout=add_border("To be or not to be!",style=’DOUBLE’) call write_text()

! scalar string uline="To be or not to be!" textout=add_border(uline,style=’light’) call write_text()

contains subroutine write_text() integer :: i write(*,’(*(a:))’,advance=’no’) & & (trim(textout(i)%character()), & & new_line(’a’), & & i=1,size(textout)) end subroutine write_text

end program demo_add_border

Results:

   >
   > one
   > two
   > three
   > four
   > ┏━━━━━━━━━━┓
   > ┃one       ┃
   > ┃two       ┃
   > ┃three     ┃
   > ┃four      ┃
   > ┗━━━━━━━━━━┛
   > ┏━━━━━┓
   > ┃one  ┃
   > ┃two  ┃
   > ┃three┃
   > ┃four ┃
   > ┗━━━━━┛
   > ╔═══════╗
   > ║┏━━━━━┓║
   > ║┃one  ┃║
   > ║┃two  ┃║
   > ║┃three┃║
   > ║┃four ┃║
   > ║┗━━━━━┛║
   > ╚═══════╝
   > ╔═══════════════════╗
   > ║To be or not to be!║
   > ╚═══════════════════╝
   > ┌───────────────────┐
   > │To be or not to be!│
   > └───────────────────┘

AUTHOR

John S. Urban

LICENSE

    MIT