diff options
author | Jeffrey Armstrong <jeff@approximatrix.com> | 2020-04-24 21:47:09 -0400 |
---|---|---|
committer | Jeffrey Armstrong <jeff@approximatrix.com> | 2020-04-24 21:47:09 -0400 |
commit | eb8d9bc74a0624dbc98ffb75268a3ba57bd43b40 (patch) | |
tree | 04e77c082b1c87778f06fe53798db6bb284f834c /dumb_render.f90 | |
download | LR-87-eb8d9bc74a0624dbc98ffb75268a3ba57bd43b40.tar.gz LR-87-eb8d9bc74a0624dbc98ffb75268a3ba57bd43b40.zip |
Initial code commit
Diffstat (limited to 'dumb_render.f90')
-rw-r--r-- | dumb_render.f90 | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/dumb_render.f90 b/dumb_render.f90 new file mode 100644 index 0000000..f50efe1 --- /dev/null +++ b/dumb_render.f90 @@ -0,0 +1,93 @@ +module dumb_render +use render +implicit none + + type, extends(renderer) :: dumb_renderer + + contains + + procedure :: initialize => dumb_initialize + + procedure :: text_width => dumb_text_width + procedure :: text_height => dumb_text_height + procedure :: is_text_visible => dumb_text_visible + + procedure :: draw_porportional => dumb_text_draw + + procedure :: preformatted_width => dumb_text_width + procedure :: preformatted_height => dumb_text_height + procedure :: is_preformatted_visible => dumb_text_visible + + procedure :: draw_preformatted => dumb_text_draw + + end type dumb_renderer + +contains + + subroutine dumb_initialize(self) + implicit none + + class(dumb_renderer)::self + + self%max_width = 79 + self%y = 0 + + end subroutine dumb_initialize + + function dumb_text_width(self, text) + implicit none + + class(dumb_renderer)::self + character(*), intent(in)::text + integer::dumb_text_width + + dumb_text_width = len_trim(text) + + end function dumb_text_width + + function dumb_text_height(self, text) + implicit none + + class(dumb_renderer)::self + character(*), intent(in)::text + integer::dumb_text_height + + dumb_text_height = 1 + + end function dumb_text_height + + function dumb_text_visible(self, text) + implicit none + + class(dumb_renderer)::self + character(*), intent(in)::text + logical::dumb_text_visible + + dumb_text_visible = (self%y >= 0 .AND. self%y < 24) + + end function dumb_text_visible + + subroutine dumb_text_draw(self, text) + implicit none + + class(dumb_renderer)::self + character(*), intent(in)::text + integer::limit_x + character(5)::formatting + + limit_x = min(len_trim(text), self%max_width) + if(limit_x == 0) then + write(*,*) " " + else + if(limit_x < 10) then + write(formatting, '(A2, I1, A1)') '(A', limit_x, ')' + else + write(formatting, '(A2, I2, A1)') '(A', limit_x, ')' + end if + + write(*, formatting) text(1:limit_x) + end if + + end subroutine dumb_text_draw + +end module dumb_render
\ No newline at end of file |