Fortran · 828 bytes Raw Blame History
1 program diff_render_demo
2 use fgof_screen, only : allocate_screen, diff_screen, put_glyph, render_screen_diff_ansi, set_cursor
3 use fgof_screen_types, only : screen_buffer, screen_diff
4 implicit none
5
6 type(screen_buffer) :: previous
7 type(screen_buffer) :: current
8 type(screen_diff) :: diff
9 character(len=:), allocatable :: rendered
10
11 previous = allocate_screen(3, 1)
12 call put_glyph(previous, 1, 1, "A")
13 call put_glyph(previous, 1, 2, "B")
14 call put_glyph(previous, 1, 3, "C")
15
16 current = previous
17 call put_glyph(current, 1, 2, "X")
18 call set_cursor(current, 1, 2)
19
20 diff = diff_screen(previous, current)
21 rendered = render_screen_diff_ansi(previous, current)
22
23 write(*, "(a, i0)") "damage-cells=", diff%damage%changed_cells
24 write(*, "(a, i0)") "diff-bytes=", len(rendered)
25 end program diff_render_demo
26