Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
szaghi committed Jun 11, 2017
2 parents 94b9d4a + 0d2e83e commit ce08c5f
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 88 deletions.
6 changes: 4 additions & 2 deletions fobos
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ build_dir = ./exe/
compiler = gnu
cflags = $CSHARED_GNU $OPTIMIZE
lflags = $LSHARED $OPTIMIZE
preproc = -DUCS4_SUPPORTED -DASCII_SUPPORTED
exclude_dirs = $EXDIRS
mod_dir = ./mod/
obj_dir = ./obj/
Expand All @@ -120,6 +121,7 @@ jobs = 2
[template-static-gnu]
compiler = gnu
cflags = $CSTATIC_GNU $OPTIMIZE
preproc = -DUCS4_SUPPORTED -DASCII_SUPPORTED
exclude_dirs = $EXDIRS
mod_dir = ./mod/
obj_dir = ./obj/
Expand All @@ -133,7 +135,7 @@ jobs = 2
compiler = gnu
cflags = $CSHARED_GNU $DEBUG_GNU
lflags = $LSHARED $DEBUG_GNU
preproc = -DDEBUG
preproc = -DUCS4_SUPPORTED -DASCII_SUPPORTED -DDEBUG
exclude_dirs = $EXDIRS
mod_dir = ./mod/
obj_dir = ./obj/
Expand All @@ -147,7 +149,7 @@ jobs = 2
compiler = gnu
cflags = $CSTATIC_GNU $DEBUG_GNU
lflags = $DEBUG_GNU
preproc = -DDEBUG
preproc = -DUCS4_SUPPORTED -DASCII_SUPPORTED -DDEBUG
exclude_dirs = $EXDIRS
mod_dir = ./mod/
obj_dir = ./obj/
Expand Down
4 changes: 4 additions & 0 deletions src/lib/forbear.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
module forbear
!< **forbear** project, Fortran (progress) B(e)ar environment.
use forbear_bar_object, only : bar_object
use forbear_kinds, only : ASCII, UCS4

implicit none
private
public :: bar_object
public :: ASCII
public :: UCS4
endmodule forbear
174 changes: 100 additions & 74 deletions src/lib/forbear_bar_object.f90 → src/lib/forbear_bar_object.F90

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ module forbear_element_object
!< **forbear** project, definition of [[element_object]].
use, intrinsic :: iso_fortran_env, only : I4P=>int32, R8P=>real32, stdout=>output_unit
use face, only : colorize
use forbear_kinds, only : ASCII, UCS4
implicit none
private
public :: element_object

type :: element_object
!< Bar element class.
character(len=:), allocatable :: string !< Element string.
character(len=:), allocatable :: color_fg !< Foreground color.
character(len=:), allocatable :: color_bg !< Background color.
character(len=:), allocatable :: style !< Style.
character(len=:, kind=UCS4), allocatable :: string !< Element string.
character(len=:), allocatable :: color_fg !< Foreground color.
character(len=:), allocatable :: color_bg !< Background color.
character(len=:), allocatable :: style !< Style.
contains
! public methods
procedure, pass(self) :: destroy !< Destroy element.
Expand All @@ -40,22 +41,36 @@ pure subroutine destroy(self)
pure subroutine initialize(self, string, color_fg, color_bg, style)
!< Initialize element.
class(element_object), intent(inout) :: self !< element.
character(len=*), intent(in), optional :: string !< Element string.
class(*), intent(in), optional :: string !< Element string.
character(len=*), intent(in), optional :: color_fg !< Foreground color.
character(len=*), intent(in), optional :: color_bg !< Background color.
character(len=*), intent(in), optional :: style !< Style.

call self%destroy
self%string = '' ; if (present(string)) self%string = string
self%string = UCS4_''
if (present(string)) then
select type(string)
#if defined ASCII_SUPPORTED && defined ASCII_NEQ_DEFAULT
type is(character(len=*, kind=ASCII))
self%string = string
#endif
#ifdef UCS4_SUPPORTED
type is(character(len=*, kind=UCS4))
self%string = string
#endif
type is(character(len=*))
self%string = string
endselect
endif
self%color_fg = '' ; if (present(color_fg)) self%color_fg = color_fg
self%color_bg = '' ; if (present(color_bg)) self%color_bg = color_bg
self%style = '' ; if (present(style)) self%style = style
endsubroutine initialize

pure function output(self)
!< Return formatted output of element.
class(element_object), intent(in) :: self !< element.
character(len=:), allocatable :: output !< Formatted output.
class(element_object), intent(in) :: self !< element.
character(len=:, kind=UCS4), allocatable :: output !< Formatted output.

output = colorize(self%string, color_fg=self%color_fg, color_bg=self%color_bg, style=self%style)
endfunction output
Expand All @@ -72,4 +87,3 @@ pure subroutine assign_element(lhs, rhs)
if (allocated(rhs%style)) lhs%style = rhs%style
endsubroutine assign_element
endmodule forbear_element_object

20 changes: 20 additions & 0 deletions src/lib/forbear_kinds.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
!< **forbear** project, definition of parametric kinds.

module forbear_kinds
!< **forbear** project, definition of parametric kinds.
implicit none
private
public :: ASCII
public :: UCS4

#ifdef ASCII_SUPPORTED
integer, parameter :: ASCII = selected_char_kind('ascii') !< ASCII character set kind.
#else
integer, parameter :: ASCII = selected_char_kind('default') !< ASCII character set kind.
#endif
#ifdef UCS4_SUPPORTED
integer, parameter :: UCS4 = selected_char_kind('iso_10646') !< Unicode character set kind.
#else
integer, parameter :: UCS4 = selected_char_kind('default') !< Unicode character set kind.
#endif
endmodule forbear_kinds
17 changes: 15 additions & 2 deletions src/tests/forbear_test.f90 → src/tests/forbear_test.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
program forbear_minimal
!< **forbear** test.
use, intrinsic :: iso_fortran_env, only : I4P=>int32, R8P=>real64
use forbear, only : bar_object
use forbear, only : bar_object, UCS4
implicit none

type(bar_object) :: bar
Expand All @@ -18,7 +18,7 @@ program forbear_minimal
call bar%initialize(width=0, add_progress_percent=.true., progress_percent_color_fg='yellow')
call worker

print '(A)', 'Fancy bar'
print '(A)', 'Fancy ASCII bar'
call bar%initialize(width=32, &
bracket_left_string='|', bracket_left_color_fg='blue', &
empty_char_string='o', empty_char_color_fg='blue', empty_char_color_bg='white', &
Expand All @@ -31,6 +31,19 @@ program forbear_minimal
add_scale_bar=.true., scale_bar_color_fg='blue', scale_bar_style='underline_on')
call worker

#ifdef UCS4_SUPPORTED
print '(A)', 'Fancy UCS4 bar'
call bar%initialize(width=32, &
bracket_left_string='|', bracket_left_color_fg='blue', &
empty_char_string=UCS4_'', empty_char_color_fg='blue', &
filled_char_string=UCS4_'', filled_char_color_fg='blue', &
bracket_right_string='|', bracket_right_color_fg='blue', &
prefix_string='ƥƦōƔƦĘşş ', prefix_color_fg='red', &
add_progress_percent=.true., progress_percent_color_fg='yellow', &
add_progress_speed=.true., progress_speed_color_fg='green')
call worker
#endif

contains
subroutine worker
!< The worker.
Expand Down

0 comments on commit ce08c5f

Please sign in to comment.