fortrangoingonforty/facsimile / 8d65cbf

Browse files

flatten fuss mode

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
8d65cbf35c9f74553a65a65cb8b2960dd4dfa40e
Parents
03dbddb
Tree
0ea98f8

5 changed files

StatusFile+-
M app/main.f90 2 0
M src/commands/command_handler_module.f90 8 3
M src/fortress/fortress_navigator_module.f90 6 7
M src/ui/help_display_module.f90 1 1
M src/workspace/file_tree_renderer_module.f90 22 31
app/main.f90modified
@@ -277,6 +277,7 @@ program facsimile
277277
         end if
278278
 
279279
         if (status == 0) then
280
+            if (allocated(editor%filename)) deallocate(editor%filename)
280281
             allocate(character(len=len_trim(filename)) :: editor%filename)
281282
             editor%filename = trim(filename)
282283
         else if (status == -2) then
@@ -313,6 +314,7 @@ program facsimile
313314
         else
314315
             ! If file doesn't exist, create empty buffer for new file
315316
             call init_buffer(buffer)
317
+            if (allocated(editor%filename)) deallocate(editor%filename)
316318
             allocate(character(len=len_trim(filename)) :: editor%filename)
317319
             editor%filename = trim(filename)
318320
         end if
src/commands/command_handler_module.f90modified
@@ -93,9 +93,10 @@ contains
9393
             match_case_sensitive = .true.  ! Reset to default
9494
         end if
9595
 
96
-        ! Route input when in fuss mode (except ctrl-b/F2 and ctrl-q which work in both modes)
96
+        ! Route input when in fuss mode (except ctrl-b/ctrl-shift-b/F2/F3 and ctrl-q which work in both modes)
9797
         if (editor%fuss_mode_active .and. trim(key_str) /= 'ctrl-b' .and. &
98
-            trim(key_str) /= 'f2' .and. trim(key_str) /= 'ctrl-q') then
98
+            trim(key_str) /= 'ctrl-shift-b' .and. trim(key_str) /= 'f2' .and. &
99
+            trim(key_str) /= 'f3' .and. trim(key_str) /= 'ctrl-q') then
99100
             call handle_fuss_input(key_str, editor, buffer)
100101
             return
101102
         end if
@@ -105,8 +106,12 @@ contains
105106
         case('ctrl-q')
106107
             should_quit = .true.
107108
 
108
-        case('ctrl-b', 'f2')
109
+        case('ctrl-b', 'ctrl-shift-b', 'f2', 'f3')
109110
             ! Toggle fuss mode (file tree)
111
+            ! ctrl-b: Original binding (conflicts with tmux prefix)
112
+            ! ctrl-shift-b: Alternative (tmux may still catch this)
113
+            ! f2: Alternative function key binding
114
+            ! f3: Tmux/terminal-safe alternative (recommended)
110115
             call toggle_fuss_mode(editor)
111116
 
112117
         case('ctrl-o')
src/fortress/fortress_navigator_module.f90modified
@@ -136,16 +136,15 @@ contains
136136
                     cancelled = .true.
137137
                     running = .false.
138138
 
139
-                case (char(10), char(13))  ! Enter - select current item
139
+                case (char(10), char(13))  ! Enter - select current item (file or directory)
140140
                     if (current_count > 0) then
141141
                         if (current_is_dir(selected)) then
142
-                            ! Enter directory
143
-                            temp_dir = current_dir
144
-                            current_dir = join_path(current_dir, trim(current_files(selected)))
145
-                            selected = 1
146
-                            scroll_offset = 0
142
+                            ! Select directory and exit
143
+                            selected_path = join_path(current_dir, trim(current_files(selected)))
144
+                            is_directory = .true.
145
+                            running = .false.
147146
                         else
148
-                            ! Select file
147
+                            ! Select file and exit
149148
                             selected_path = join_path(current_dir, trim(current_files(selected)))
150149
                             is_directory = .false.
151150
                             running = .false.
src/ui/help_display_module.f90modified
@@ -67,7 +67,7 @@ contains
6767
             call get_key_input(key_input, status)
6868
             if (status == 0) then
6969
                 select case(trim(key_input))
70
-                case('q', 'Q', 'esc')
70
+                case('q', 'Q', 'esc', 'ctrl-/', 'ctrl-?')
7171
                     done = .true.
7272
                 case('up', 'k')
7373
                     if (viewport_start > 1) viewport_start = viewport_start - 1
src/workspace/file_tree_renderer_module.f90modified
@@ -7,10 +7,9 @@ module file_tree_renderer_module
77
 
88
     public :: render_file_tree
99
 
10
-    ! UTF-8 box-drawing characters
11
-    character(len=*), parameter :: BRANCH_LAST = '└──'
12
-    character(len=*), parameter :: BRANCH_MID = '├──'
13
-    character(len=*), parameter :: VERTICAL = '│'
10
+    ! Simple expansion indicators (no box-drawing)
11
+    character(len=*), parameter :: EXPANDED_DIR = '-'
12
+    character(len=*), parameter :: COLLAPSED_DIR = '+'
1413
     character(len=1), parameter :: ESC = achar(27)
1514
 
1615
 contains
@@ -87,7 +86,7 @@ contains
8786
                 ! Fourth row: exit
8887
                 call terminal_move_cursor(end_row, start_col)
8988
                 call terminal_write(ESC // '[90m') ! Gray
90
-                call terminal_write('ctrl-/:collapse esc/ctrl-b:close')
89
+                call terminal_write('ctrl-/:collapse esc/F3:close')
9190
                 call terminal_write(ESC // '[0m')
9291
             end if
9392
         else
@@ -95,7 +94,7 @@ contains
9594
             if (end_row >= start_row + 1) then
9695
                 call terminal_move_cursor(end_row, start_col)
9796
                 call terminal_write(ESC // '[90m') ! Gray
98
-                call terminal_write('.:hide  ctrl-/:hints  esc/ctrl-b:close')
97
+                call terminal_write('.:hide  ctrl-/:hints  esc/F3:close')
9998
                 call terminal_write(ESC // '[0m')
10099
             end if
101100
         end if
@@ -110,7 +109,7 @@ contains
110109
         integer, intent(inout) :: item_idx, current_row
111110
         integer, intent(in) :: end_row, start_col, width
112111
 
113
-        character(len=:), allocatable :: line, new_prefix, branch
112
+        character(len=:), allocatable :: line, new_prefix
114113
         type(tree_node_t), pointer :: child
115114
         logical :: is_selected, is_last_child
116115
 
@@ -127,24 +126,23 @@ contains
127126
 
128127
             ! Only render if within viewport and current_row fits
129128
             if (item_idx >= state%viewport_offset .and. current_row <= end_row) then
130
-                ! Build line with tree structure
131
-                if (is_last) then
132
-                    branch = BRANCH_LAST
133
-                else
134
-                    branch = BRANCH_MID
135
-                end if
136
-
137
-                ! Construct the line - prefix can be empty string, that's fine
138
-                if (.not. node%is_file .and. associated(node%first_child)) then
139
-                    ! Directory with children - add expand/collapse indicator
140
-                    if (node%expanded) then
141
-                        line = prefix // branch // ' ▾ ' // trim(node%name)
129
+                ! Build line with simple +/- indicators and indentation
130
+                if (.not. node%is_file) then
131
+                    ! Directory - add expand/collapse indicator and / suffix
132
+                    if (associated(node%first_child)) then
133
+                        ! Directory with children
134
+                        if (node%expanded) then
135
+                            line = prefix // EXPANDED_DIR // ' ' // trim(node%name) // '/'
136
+                        else
137
+                            line = prefix // COLLAPSED_DIR // ' ' // trim(node%name) // '/'
138
+                        end if
142139
                     else
143
-                        line = prefix // branch // ' ▸ ' // trim(node%name)
140
+                        ! Empty directory - no expand/collapse indicator
141
+                        line = prefix // '  ' // trim(node%name) // '/'
144142
                     end if
145143
                 else
146
-                    ! File or empty directory - no indicator
147
-                    line = prefix // branch // ' ' // trim(node%name)
144
+                    ! File - just indentation and name
145
+                    line = prefix // '  ' // trim(node%name)
148146
                 end if
149147
 
150148
                 ! Add status indicators for files only
@@ -194,15 +192,8 @@ contains
194192
                 ! Root's children start with no prefix
195193
                 new_prefix = ''
196194
             else
197
-                ! Non-root children inherit prefix and add continuation
198
-                ! IMPORTANT: Don't trim prefix! It contains accumulated indentation
199
-                if (is_last) then
200
-                    ! Current node is last, so children get spaces (no vertical line continues)
201
-                    new_prefix = prefix // '    '
202
-                else
203
-                    ! Current node is not last, so vertical line continues for children
204
-                    new_prefix = prefix // VERTICAL // '   '
205
-                end if
195
+                ! Non-root children inherit prefix and add 2-space indentation
196
+                new_prefix = prefix // '  '
206197
             end if
207198
 
208199
             call render_tree_node(child, new_prefix, is_last_child, .false., &