| 1 | program test_display_sim |
| 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 | character(len=*), parameter :: DIM = ESC // "[2m" |
| 12 | integer :: i |
| 13 | |
| 14 | write(output_unit, '(a)') "Simulating fortress display rendering:" |
| 15 | write(output_unit, *) |
| 16 | |
| 17 | ! Simulate rendering 5 lines in the middle pane |
| 18 | do i = 1, 5 |
| 19 | ! Separator (like fortress does) |
| 20 | write(output_unit, '(a)', advance='no') " │ " |
| 21 | |
| 22 | ! NOREVERSE at start of line (like our fix) |
| 23 | write(output_unit, '(a)', advance='no') NOREVERSE |
| 24 | |
| 25 | ! Render line |
| 26 | if (i == 3) then |
| 27 | ! This is the cursor line - should be reversed |
| 28 | write(output_unit, '(a)', advance='no') REVERSE // BLUE // BOLD // "CURSOR_LINE" |
| 29 | write(output_unit, '(a)', advance='no') NOREVERSE |
| 30 | write(output_unit, '(a)') RESET |
| 31 | else |
| 32 | ! Normal line - should NOT be reversed |
| 33 | write(output_unit, '(a)', advance='no') BLUE // BOLD // "normal_line_" // char(48+i) |
| 34 | write(output_unit, '(a)') RESET |
| 35 | end if |
| 36 | end do |
| 37 | |
| 38 | write(output_unit, *) |
| 39 | write(output_unit, '(a)') "If ALL lines above are reversed, we have a deeper issue" |
| 40 | write(output_unit, '(a)') "If only CURSOR_LINE is reversed, the code logic is correct" |
| 41 | |
| 42 | end program test_display_sim |
| 43 |