| 1 | program test_ansi |
| 2 | use iso_fortran_env, only: output_unit |
| 3 | implicit none |
| 4 | |
| 5 | character(len=*), parameter :: ESC = char(27) |
| 6 | character(len=*), parameter :: REVERSE = ESC // "[7m" |
| 7 | character(len=*), parameter :: NOREVERSE = ESC // "[27m" |
| 8 | character(len=*), parameter :: RESET = ESC // "[0m" |
| 9 | character(len=*), parameter :: BLUE = ESC // "[34m" |
| 10 | character(len=*), parameter :: BOLD = ESC // "[1m" |
| 11 | |
| 12 | ! Test 1: Reverse line followed by normal lines |
| 13 | write(output_unit, '(a)') "Test 1: One reversed line followed by normal lines" |
| 14 | write(output_unit, '(a)', advance='no') REVERSE // BLUE // BOLD // "CURSOR LINE" |
| 15 | write(output_unit, '(a)', advance='no') NOREVERSE |
| 16 | write(output_unit, '(a)') RESET |
| 17 | write(output_unit, '(a)') NOREVERSE // BLUE // BOLD // "Normal line 1" |
| 18 | write(output_unit, '(a)') NOREVERSE // BLUE // BOLD // "Normal line 2" |
| 19 | write(output_unit, '(a)') NOREVERSE // BLUE // BOLD // "Normal line 3" |
| 20 | |
| 21 | write(output_unit, *) |
| 22 | write(output_unit, '(a)') "If lines 1-3 above are reversed, the bug is in Fortran's output handling" |
| 23 | write(output_unit, '(a)') "If only CURSOR LINE is reversed, the fix is working" |
| 24 | |
| 25 | end program test_ansi |
| 26 |