fortrangoingonforty/fortress / 8bd51f7

Browse files

alacritty fixes needs testing on other terms

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
8bd51f7eb2af283f579183b353ba3bf6cdf756d1
Parents
3e78f26
Tree
e05e2c7

4 changed files

StatusFile+-
M app/main.f90 8 3
A check_alacritty.sh 11 0
M src/terminal/term_control.f90 43 1
M src/ui/display.f90 9 1
app/main.f90modified
@@ -105,7 +105,7 @@ program fortress
105
 
105
 
106
         ! Get terminal size
106
         ! Get terminal size
107
         call get_term_size(rows, cols)
107
         call get_term_size(rows, cols)
108
-        visible_height = rows - 3
108
+        visible_height = rows - 6  ! Account for 2 pre-spacing + header + 2 post-spacing + footer
109
 
109
 
110
         ! Handle navigation signals from previous iteration
110
         ! Handle navigation signals from previous iteration
111
         if (selected == -1) then
111
         if (selected == -1) then
@@ -441,6 +441,11 @@ program fortress
441
                 ! Check if we have disjoint selections
441
                 ! Check if we have disjoint selections
442
                 call check_disjoint_selection(is_selected, current_count, has_disjoint_selection)
442
                 call check_disjoint_selection(is_selected, current_count, has_disjoint_selection)
443
             end if
443
             end if
444
+        case(69, 101)  ! 'E' or 'e' - exit/clear multi-select mode
445
+            if (selection_count > 0) then
446
+                call clear_all_selections(is_selected, selection_count, in_selection_mode)
447
+                selection_anchor = -1
448
+            end if
444
         case(86, 118)  ! 'V' or 'v' - enter move mode OR confirm move
449
         case(86, 118)  ! 'V' or 'v' - enter move mode OR confirm move
445
             if (move_mode) then
450
             if (move_mode) then
446
                 ! Confirm move - execute the move to the white-highlighted directory
451
                 ! Confirm move - execute the move to the white-highlighted directory
@@ -1305,7 +1310,7 @@ contains
1305
         call execute_command_line("rm -f ~/.fortress_fav_temp ~/.fortress_fav_select 2>/dev/null")
1310
         call execute_command_line("rm -f ~/.fortress_fav_temp ~/.fortress_fav_select 2>/dev/null")
1306
 
1311
 
1307
         ! Re-enable raw mode
1312
         ! Re-enable raw mode
1308
-        call execute_command_line("stty -icanon -echo min 1 time 0 2>/dev/null", wait=.true.)
1313
+        call setup_raw_mode()
1309
     end subroutine add_favorite_with_replacement
1314
     end subroutine add_favorite_with_replacement
1310
 
1315
 
1311
     subroutine mark_favorites_in_lists(current_dir, files, count, is_dir, favs, fav_count, is_fav)
1316
     subroutine mark_favorites_in_lists(current_dir, files, count, is_dir, favs, fav_count, is_fav)
@@ -1389,7 +1394,7 @@ contains
1389
         call execute_command_line("rm -f ~/.fortress_fav_picker ~/.fortress_fav_selected 2>/dev/null")
1394
         call execute_command_line("rm -f ~/.fortress_fav_picker ~/.fortress_fav_selected 2>/dev/null")
1390
 
1395
 
1391
         ! Re-enable raw mode
1396
         ! Re-enable raw mode
1392
-        call execute_command_line("stty -icanon -echo min 1 time 0 2>/dev/null", wait=.true.)
1397
+        call setup_raw_mode()
1393
     end subroutine open_favorites_picker
1398
     end subroutine open_favorites_picker
1394
 
1399
 
1395
 end program fortress
1400
 end program fortress
check_alacritty.shadded
@@ -0,0 +1,11 @@
1
+#!/bin/bash
2
+# Script to check alacritty environment variables
3
+
4
+echo "=== Terminal Environment Check ==="
5
+echo "TERM=$TERM"
6
+echo "ALACRITTY_SOCKET=$ALACRITTY_SOCKET"
7
+echo "ALACRITTY_LOG=$ALACRITTY_LOG"
8
+echo "ALACRITTY_WINDOW_ID=$ALACRITTY_WINDOW_ID"
9
+echo ""
10
+echo "All environment variables containing 'alacritty' or 'ALACRITTY':"
11
+env | grep -i alacritty
src/terminal/term_control.f90modified
@@ -4,6 +4,8 @@ module terminal_control
4
     private
4
     private
5
 
5
 
6
     public :: get_term_size, setup_raw_mode, restore_terminal, read_arrow_key, read_arrow_key_with_shift
6
     public :: get_term_size, setup_raw_mode, restore_terminal, read_arrow_key, read_arrow_key_with_shift
7
+    public :: enable_read_timeout, disable_read_timeout
8
+    public :: needs_extra_spacing
7
     public :: ESC, CLEAR, BOLD, DIM, REVERSE, RESET
9
     public :: ESC, CLEAR, BOLD, DIM, REVERSE, RESET
8
     public :: BLUE, GREEN, RED, GREY, WHITE, YELLOW
10
     public :: BLUE, GREEN, RED, GREY, WHITE, YELLOW
9
     public :: invalidate_term_cache
11
     public :: invalidate_term_cache
@@ -84,13 +86,53 @@ contains
84
     end subroutine get_term_size
86
     end subroutine get_term_size
85
 
87
 
86
     subroutine setup_raw_mode()
88
     subroutine setup_raw_mode()
87
-        call execute_command_line("stty -icanon -echo min 1 time 0 2>/dev/null")
89
+        ! Blocking mode for stable operation
90
+        call execute_command_line("stty -icanon -echo min 1 time 0 2>/dev/null", wait=.true.)
88
     end subroutine setup_raw_mode
91
     end subroutine setup_raw_mode
89
 
92
 
93
+    subroutine enable_read_timeout()
94
+        ! No-op for now
95
+    end subroutine enable_read_timeout
96
+
97
+    subroutine disable_read_timeout()
98
+        ! No-op for now
99
+    end subroutine disable_read_timeout
100
+
90
     subroutine restore_terminal()
101
     subroutine restore_terminal()
91
         call execute_command_line("stty icanon echo 2>/dev/null")
102
         call execute_command_line("stty icanon echo 2>/dev/null")
92
     end subroutine restore_terminal
103
     end subroutine restore_terminal
93
 
104
 
105
+    function needs_extra_spacing() result(needs_spacing)
106
+        logical :: needs_spacing
107
+        character(len=256) :: term_var, alacritty_var
108
+        integer :: stat
109
+
110
+        needs_spacing = .false.
111
+
112
+        ! Check TERM environment variable
113
+        call get_environment_variable("TERM", term_var, status=stat)
114
+        if (stat == 0) then
115
+            ! Check if TERM contains "alacritty" or other terminals that need spacing
116
+            if (index(term_var, "alacritty") > 0) then
117
+                needs_spacing = .true.
118
+                return
119
+            end if
120
+        end if
121
+
122
+        ! Also check for ALACRITTY_SOCKET or ALACRITTY_LOG to detect alacritty
123
+        call get_environment_variable("ALACRITTY_SOCKET", alacritty_var, status=stat)
124
+        if (stat == 0 .and. len_trim(alacritty_var) > 0) then
125
+            needs_spacing = .true.
126
+            return
127
+        end if
128
+
129
+        call get_environment_variable("ALACRITTY_LOG", alacritty_var, status=stat)
130
+        if (stat == 0 .and. len_trim(alacritty_var) > 0) then
131
+            needs_spacing = .true.
132
+            return
133
+        end if
134
+    end function needs_extra_spacing
135
+
94
     subroutine read_arrow_key(k)
136
     subroutine read_arrow_key(k)
95
         character(len=1), intent(out) :: k
137
         character(len=1), intent(out) :: k
96
         character(len=1) :: ch
138
         character(len=1) :: ch
src/ui/display.f90modified
@@ -41,7 +41,11 @@ contains
41
         character(len=20) :: color_code
41
         character(len=20) :: color_code
42
 
42
 
43
         left_w = c * 3 / 10
43
         left_w = c * 3 / 10
44
-        vis_h = r - 3  ! Visible height
44
+        vis_h = r - 6  ! Visible height (2 pre-spacing + header + 2 post-spacing + footer)
45
+
46
+        ! Add spacing at the very top to prevent terminal cutoff
47
+        write(output_unit, *)
48
+        write(output_unit, *)
45
 
49
 
46
         ! Header
50
         ! Header
47
         if (move_mode) then
51
         if (move_mode) then
@@ -75,6 +79,10 @@ contains
75
             write(output_unit, '(a)') BOLD // "FORTRESS" // RESET // " - " // trim(current_dir)
79
             write(output_unit, '(a)') BOLD // "FORTRESS" // RESET // " - " // trim(current_dir)
76
         end if
80
         end if
77
 
81
 
82
+        ! Add extra spacing - many terminals need this to prevent header overlap
83
+        write(output_unit, *)
84
+        write(output_unit, *)
85
+
78
         ! Files (render based on scroll offsets)
86
         ! Files (render based on scroll offsets)
79
         do i = 1, vis_h
87
         do i = 1, vis_h
80
             parent_idx = i + parent_scroll_offset
88
             parent_idx = i + parent_scroll_offset