@@ -0,0 +1,38 @@ |
| 1 | +program test_screen_render_edges |
| 2 | + use fgof_screen, only : & |
| 3 | + allocate_screen, & |
| 4 | + render_screen_ansi, & |
| 5 | + render_screen_diff_ansi, & |
| 6 | + set_cursor |
| 7 | + use fgof_screen_types, only : screen_buffer |
| 8 | + implicit none |
| 9 | + |
| 10 | + type(screen_buffer) :: previous |
| 11 | + type(screen_buffer) :: current |
| 12 | + character(len=:), allocatable :: rendered |
| 13 | + character(len=:), allocatable :: esc |
| 14 | + character(len=:), allocatable :: expected |
| 15 | + |
| 16 | + esc = achar(27) // "[" |
| 17 | + |
| 18 | + previous = allocate_screen(0, 0) |
| 19 | + rendered = render_screen_ansi(previous) |
| 20 | + expected = esc // "?25l" // esc // "2J" // esc // "H" // esc // "0m" // esc // "1;1H" // esc // "?25h" |
| 21 | + if (rendered /= expected) error stop "empty full render should still clear, reset style, and restore cursor state" |
| 22 | + |
| 23 | + current = allocate_screen(2, 2) |
| 24 | + previous = current |
| 25 | + rendered = render_screen_diff_ansi(previous, current) |
| 26 | + if (rendered /= "") error stop "identical screens should produce an empty diff render" |
| 27 | + |
| 28 | + call set_cursor(current, 2, 2) |
| 29 | + rendered = render_screen_diff_ansi(previous, current) |
| 30 | + expected = esc // "2;2H" // esc // "?25h" |
| 31 | + if (rendered /= expected) error stop "cursor-only diffs should render only final cursor output" |
| 32 | + |
| 33 | + current = previous |
| 34 | + current%cursor_visible = .false. |
| 35 | + rendered = render_screen_diff_ansi(previous, current) |
| 36 | + expected = esc // "?25l" |
| 37 | + if (rendered /= expected) error stop "cursor-visibility-only diffs should render only the visibility change" |
| 38 | +end program test_screen_render_edges |