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
105105
 
106106
         ! Get terminal size
107107
         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
109109
 
110110
         ! Handle navigation signals from previous iteration
111111
         if (selected == -1) then
@@ -441,6 +441,11 @@ program fortress
441441
                 ! Check if we have disjoint selections
442442
                 call check_disjoint_selection(is_selected, current_count, has_disjoint_selection)
443443
             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
444449
         case(86, 118)  ! 'V' or 'v' - enter move mode OR confirm move
445450
             if (move_mode) then
446451
                 ! Confirm move - execute the move to the white-highlighted directory
@@ -1305,7 +1310,7 @@ contains
13051310
         call execute_command_line("rm -f ~/.fortress_fav_temp ~/.fortress_fav_select 2>/dev/null")
13061311
 
13071312
         ! 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()
13091314
     end subroutine add_favorite_with_replacement
13101315
 
13111316
     subroutine mark_favorites_in_lists(current_dir, files, count, is_dir, favs, fav_count, is_fav)
@@ -1389,7 +1394,7 @@ contains
13891394
         call execute_command_line("rm -f ~/.fortress_fav_picker ~/.fortress_fav_selected 2>/dev/null")
13901395
 
13911396
         ! 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()
13931398
     end subroutine open_favorites_picker
13941399
 
13951400
 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
44
     private
55
 
66
     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
79
     public :: ESC, CLEAR, BOLD, DIM, REVERSE, RESET
810
     public :: BLUE, GREEN, RED, GREY, WHITE, YELLOW
911
     public :: invalidate_term_cache
@@ -84,13 +86,53 @@ contains
8486
     end subroutine get_term_size
8587
 
8688
     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.)
8891
     end subroutine setup_raw_mode
8992
 
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
+
90101
     subroutine restore_terminal()
91102
         call execute_command_line("stty icanon echo 2>/dev/null")
92103
     end subroutine restore_terminal
93104
 
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
+
94136
     subroutine read_arrow_key(k)
95137
         character(len=1), intent(out) :: k
96138
         character(len=1) :: ch
src/ui/display.f90modified
@@ -41,7 +41,11 @@ contains
4141
         character(len=20) :: color_code
4242
 
4343
         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, *)
4549
 
4650
         ! Header
4751
         if (move_mode) then
@@ -75,6 +79,10 @@ contains
7579
             write(output_unit, '(a)') BOLD // "FORTRESS" // RESET // " - " // trim(current_dir)
7680
         end if
7781
 
82
+        ! Add extra spacing - many terminals need this to prevent header overlap
83
+        write(output_unit, *)
84
+        write(output_unit, *)
85
+
7886
         ! Files (render based on scroll offsets)
7987
         do i = 1, vis_h
8088
             parent_idx = i + parent_scroll_offset