fortrangoingonforty/fortress / 5dda99d

Browse files

track these i guess

Authored by espadonne
SHA
5dda99d364a25bdec8291feeac8ff47f9534543f
Parents
e13b7ce
Tree
d2aed2b

7 changed files

StatusFile+-
A test/test_ansi.sh 28 0
A test/test_display_sim bin
A test/test_display_sim.f90 42 0
A test/test_fortran_ansi bin
A test/test_fortran_ansi.f90 25 0
A test/test_interactive.sh 36 0
A test/test_reverse.sh 16 0
test/test_ansi.shadded
@@ -0,0 +1,28 @@
1
+#!/bin/bash
2
+# Test ANSI color rendering similar to fortress
3
+
4
+echo "Testing ANSI codes as fortress uses them:"
5
+echo ""
6
+
7
+# Test 1: Normal color + filename
8
+printf '\033[34m\033[1mDirectory/\033[0m\n'
9
+printf '\033[37mFile.txt\033[0m\n'
10
+printf '\033[32mExecutable\033[0m\n'
11
+
12
+echo ""
13
+echo "Testing REVERSE (cursor highlight):"
14
+
15
+# Test 2: Reverse video with color
16
+printf '\033[7m\033[34m\033[1mDirectory/\033[0m\n'
17
+printf '\033[7m\033[37mFile.txt\033[0m\n'
18
+
19
+echo ""
20
+echo "Testing sequence like fortress renders:"
21
+
22
+# Test 3: Full sequence like display.f90 does
23
+printf '\033[34m\033[1mdir1/\033[0m\n'
24
+printf '\033[7m\033[34m\033[1mdir2/\033[0m <- This should be highlighted\n'
25
+printf '\033[37mfile1.txt\033[0m\n'
26
+
27
+echo ""
28
+echo "If 'dir2/' above does NOT look different (reversed), that's the bug."
test/test_display_simadded
Binary file changed.
test/test_display_sim.f90added
@@ -0,0 +1,42 @@
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
test/test_fortran_ansiadded
Binary file changed.
test/test_fortran_ansi.f90added
@@ -0,0 +1,25 @@
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
test/test_interactive.shadded
@@ -0,0 +1,36 @@
1
+#!/bin/bash
2
+# This demonstrates the proper usage
3
+
4
+echo "==== FORTRESS CD-ON-EXIT TEST ===="
5
+echo ""
6
+echo "1. First, source the fortress function:"
7
+echo "   source ~/Documents/GithubOrgs/FortranGoingOnForty/fortress/fortress.sh"
8
+echo ""
9
+echo "2. Then run: fortress"
10
+echo ""
11
+echo "3. Navigate to a directory you want to cd to"
12
+echo ""
13
+echo "4. Press 'c' on that directory"
14
+echo ""
15
+echo "5. Your shell should cd to that directory"
16
+echo ""
17
+echo "==== TRY THIS IN YOUR TERMINAL ===="
18
+echo ""
19
+echo "Current directory: $(pwd)"
20
+echo ""
21
+
22
+# Source fortress
23
+source ~/Documents/GithubOrgs/FortranGoingOnForty/fortress/fortress.sh
24
+
25
+# Simulate what happens when you press 'c' in fortress
26
+echo "Simulating: you pressed 'c' on the docs/ directory..."
27
+mkdir -p ~/Documents/GithubOrgs/FortranGoingOnForty/fortress/docs
28
+echo "~/Documents/GithubOrgs/FortranGoingOnForty/fortress/docs" > ~/.fortress_cd
29
+
30
+# This is what the fortress() function does after fortress exits
31
+if [ -f "$HOME/.fortress_cd" ]; then
32
+    target_dir=$(cat "$HOME/.fortress_cd")
33
+    rm -f "$HOME/.fortress_cd"
34
+    cd "$target_dir"
35
+    echo "✓ Changed directory to: $(pwd)"
36
+fi
test/test_reverse.shadded
@@ -0,0 +1,16 @@
1
+#!/bin/bash
2
+# Test if RESET properly clears REVERSE mode
3
+
4
+echo "Test 1: REVERSE followed by RESET (ESC[0m)"
5
+printf '\033[7mREVERSED LINE\033[0m\n'
6
+printf 'Normal line 1\n'
7
+printf 'Normal line 2\n'
8
+
9
+echo ""
10
+echo "Test 2: REVERSE followed by explicit un-reverse (ESC[27m) then RESET"
11
+printf '\033[7mREVERSED LINE\033[27m\033[0m\n'
12
+printf 'Normal line 1\n'
13
+printf 'Normal line 2\n'
14
+
15
+echo ""
16
+echo "Which test shows 'Normal line 1' and 'Normal line 2' without reverse video?"