1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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
|