fortrangoingonforty/facsimile / bdd4698

Browse files

fix compiler warnings remainder except buffer

Authored by espadonne
SHA
bdd4698d8ad1baf969682e274909dddc5153f833
Parents
8070cd7
Tree
d6ce330

5 changed files

StatusFile+-
M src/commands/command_handler_module.f90 15 173
M src/terminal/input_handler_module.f90 2 3
M src/terminal/renderer_module.f90 3 50
M src/ui/help_display_module.f90 0 25
M src/workspace/file_tree_module.f90 2 2
src/commands/command_handler_module.f90modified
@@ -257,7 +257,7 @@ contains
257257
 
258258
         ! Selection with shift+motion
259259
         case('shift-up')
260
-            call extend_selection_up(editor%cursors(editor%active_cursor), buffer, line_count)
260
+            call extend_selection_up(editor%cursors(editor%active_cursor), buffer)
261261
             call sync_editor_to_pane(editor)
262262
             call update_viewport(editor)
263263
 
@@ -314,10 +314,10 @@ contains
314314
             if (size(editor%cursors) > 1) then
315315
                 ! Move all cursors
316316
                 do i = 1, size(editor%cursors)
317
-                    call move_cursor_page_up(editor%cursors(i), editor, line_count)
317
+                    call move_cursor_page_up(editor%cursors(i), editor)
318318
                 end do
319319
             else
320
-                call move_cursor_page_up(editor%cursors(editor%active_cursor), editor, line_count)
320
+                call move_cursor_page_up(editor%cursors(editor%active_cursor), editor)
321321
             end if
322322
             call sync_editor_to_pane(editor)
323323
             call update_viewport(editor)
@@ -363,7 +363,7 @@ contains
363363
             call update_viewport(editor)
364364
 
365365
         case('shift-pageup')
366
-            call extend_selection_page_up(editor%cursors(editor%active_cursor), editor, line_count)
366
+            call extend_selection_page_up(editor%cursors(editor%active_cursor), editor)
367367
             call sync_editor_to_pane(editor)
368368
             call update_viewport(editor)
369369
 
@@ -841,7 +841,7 @@ contains
841841
             ! Add cursor on line above
842842
             ! opt-meta-up: Doesn't work (terminals don't send Cmd)
843843
             ! ctrl-alt-up: Alternative binding that works
844
-            call add_cursor_above(editor, buffer)
844
+            call add_cursor_above(editor)
845845
             call sync_editor_to_pane(editor)
846846
             call update_viewport(editor)
847847
 
@@ -1101,10 +1101,9 @@ contains
11011101
         if (allocated(line)) deallocate(line)
11021102
     end subroutine move_cursor_end
11031103
 
1104
-    subroutine move_cursor_page_up(cursor, editor, line_count)
1104
+    subroutine move_cursor_page_up(cursor, editor)
11051105
         type(cursor_t), intent(inout) :: cursor
11061106
         type(editor_state_t), intent(in) :: editor
1107
-        integer, intent(in) :: line_count
11081107
         integer :: page_size
11091108
 
11101109
         cursor%has_selection = .false.  ! Clear selection
@@ -1130,7 +1129,6 @@ contains
11301129
         type(buffer_t), intent(in) :: buffer
11311130
         character(len=:), allocatable :: line
11321131
         integer :: pos, line_len
1133
-        logical :: in_word
11341132
 
11351133
         cursor%has_selection = .false.  ! Clear selection
11361134
         line = buffer_get_line(buffer, cursor%line)
@@ -1201,7 +1199,6 @@ contains
12011199
         type(buffer_t), intent(in) :: buffer
12021200
         character(len=:), allocatable :: line
12031201
         integer :: pos, line_count, line_len
1204
-        logical :: in_word
12051202
 
12061203
         cursor%has_selection = .false.  ! Clear selection
12071204
         line = buffer_get_line(buffer, cursor%line)
@@ -1574,7 +1571,6 @@ contains
15741571
         character, intent(in) :: ch
15751572
         integer :: i
15761573
         integer :: offset_adjust
1577
-        integer :: cursors_before
15781574
 
15791575
         ! Sort cursors by position to handle offset adjustments
15801576
         call sort_cursors_by_position(editor)
@@ -2161,39 +2157,6 @@ contains
21612157
         end do
21622158
     end subroutine insert_line_text
21632159
 
2164
-    subroutine get_line_positions(buffer, line_num, start_pos, end_pos)
2165
-        type(buffer_t), intent(in) :: buffer
2166
-        integer, intent(in) :: line_num
2167
-        integer, intent(out) :: start_pos, end_pos
2168
-        integer :: current_line, i
2169
-
2170
-        current_line = 1
2171
-        start_pos = 1
2172
-
2173
-        ! Find start of requested line
2174
-        do i = 1, buffer%size
2175
-            if (current_line == line_num) then
2176
-                start_pos = i
2177
-                exit
2178
-            end if
2179
-            if (i < buffer%gap_start .or. i >= buffer%gap_end) then
2180
-                if (buffer_get_char_at(buffer, i) == char(10)) then
2181
-                    current_line = current_line + 1
2182
-                end if
2183
-            end if
2184
-        end do
2185
-
2186
-        ! Find end of line
2187
-        end_pos = start_pos
2188
-        do i = start_pos, buffer%size
2189
-            if (buffer_get_char_at(buffer, i) == char(10)) then
2190
-                end_pos = i
2191
-                exit
2192
-            end if
2193
-            end_pos = i
2194
-        end do
2195
-    end subroutine get_line_positions
2196
-
21972160
     function buffer_get_char_at(buffer, pos) result(ch)
21982161
         type(buffer_t), intent(in) :: buffer
21992162
         integer, intent(in) :: pos
@@ -2289,10 +2252,9 @@ contains
22892252
     subroutine save_file(editor, buffer)
22902253
         type(editor_state_t), intent(in) :: editor
22912254
         type(buffer_t), intent(inout) :: buffer
2292
-        integer :: ios, temp_unit
2255
+        integer :: ios
22932256
         character(len=256) :: temp_filename, command
2294
-        character(len=1024) :: error_msg
2295
-        logical :: file_exists, has_write_permission
2257
+        logical :: file_exists
22962258
 
22972259
         if (.not. allocated(editor%filename)) return
22982260
 
@@ -2315,7 +2277,7 @@ contains
23152277
         inquire(file=editor%filename, exist=file_exists)
23162278
 
23172279
         ! If save failed, try sudo save
2318
-        write(temp_filename, '(a,i0)') '/tmp/facsimile_sudo_', getpid()
2280
+        write(temp_filename, '(a,i0)') '/tmp/facsimile_sudo_', get_process_id()
23192281
 
23202282
         ! Save to temporary file
23212283
         call buffer_save_file(buffer, temp_filename, ios)
@@ -2349,7 +2311,7 @@ contains
23492311
         end if
23502312
     end subroutine save_file
23512313
 
2352
-    function getpid() result(pid)
2314
+    function get_process_id() result(pid)
23532315
         integer :: pid
23542316
         interface
23552317
             function c_getpid() bind(C, name="getpid")
@@ -2358,7 +2320,7 @@ contains
23582320
             end function
23592321
         end interface
23602322
         pid = c_getpid()
2361
-    end function getpid
2323
+    end function get_process_id
23622324
 
23632325
     subroutine cycle_quotes(cursor, buffer)
23642326
         type(cursor_t), intent(inout) :: cursor
@@ -2524,7 +2486,6 @@ contains
25242486
         integer :: colon1, colon2, colon3
25252487
         character(len=100) :: event_type
25262488
         integer :: ios, line_count
2527
-        logical :: is_alt_click
25282489
         type(cursor_t), allocatable :: new_cursors(:)
25292490
         integer :: i, cursor_exists
25302491
         ! Variables for mouse drag handling
@@ -2816,77 +2777,6 @@ contains
28162777
         at_pos = (cursor_screen_row == screen_row .and. cursor_screen_col == screen_col)
28172778
     end function is_cursor_at_screen_pos
28182779
 
2819
-    subroutine toggle_cursor_at_position(editor, buffer, row, col)
2820
-        type(editor_state_t), intent(inout) :: editor
2821
-        type(buffer_t), intent(in) :: buffer
2822
-        integer, intent(in) :: row, col
2823
-        integer :: i, cursor_exists
2824
-        type(cursor_t), allocatable :: new_cursors(:)
2825
-
2826
-        ! Check if cursor already exists at this position
2827
-        cursor_exists = 0
2828
-        do i = 1, size(editor%cursors)
2829
-            if (is_cursor_at_screen_pos(editor%cursors(i), editor, row, col)) then
2830
-                cursor_exists = i
2831
-                exit
2832
-            end if
2833
-        end do
2834
-
2835
-        if (cursor_exists > 0) then
2836
-            ! Remove the cursor
2837
-            if (size(editor%cursors) > 1) then
2838
-                allocate(new_cursors(size(editor%cursors) - 1))
2839
-                do i = 1, cursor_exists - 1
2840
-                    new_cursors(i) = editor%cursors(i)
2841
-                end do
2842
-                do i = cursor_exists + 1, size(editor%cursors)
2843
-                    new_cursors(i-1) = editor%cursors(i)
2844
-                end do
2845
-                deallocate(editor%cursors)
2846
-                editor%cursors = new_cursors
2847
-                if (editor%active_cursor >= cursor_exists) then
2848
-                    editor%active_cursor = max(1, editor%active_cursor - 1)
2849
-                end if
2850
-            end if
2851
-        else
2852
-            ! Add a new cursor
2853
-            allocate(new_cursors(size(editor%cursors) + 1))
2854
-            do i = 1, size(editor%cursors)
2855
-                new_cursors(i) = editor%cursors(i)
2856
-            end do
2857
-            call init_cursor(new_cursors(size(new_cursors)))
2858
-            ! First move the new cursors to editor
2859
-            deallocate(editor%cursors)
2860
-            editor%cursors = new_cursors
2861
-            editor%active_cursor = size(editor%cursors)
2862
-            ! Then position the new cursor using its index
2863
-            call position_cursor_at_screen(editor%active_cursor, &
2864
-                                          editor, buffer, row, col)
2865
-        end if
2866
-    end subroutine toggle_cursor_at_position
2867
-
2868
-    subroutine handle_mouse_click(editor, buffer, row, col)
2869
-        type(editor_state_t), intent(inout) :: editor
2870
-        type(buffer_t), intent(in) :: buffer
2871
-        integer, intent(in) :: row, col
2872
-        integer :: cursor_idx
2873
-
2874
-        ! Clear multiple cursors
2875
-        if (allocated(editor%cursors)) then
2876
-            if (size(editor%cursors) > 1) then
2877
-                deallocate(editor%cursors)
2878
-                allocate(editor%cursors(1))
2879
-                call init_cursor(editor%cursors(1))
2880
-                editor%active_cursor = 1
2881
-            end if
2882
-        end if
2883
-
2884
-        ! Move cursor to click position
2885
-        cursor_idx = 1
2886
-        call position_cursor_at_screen(cursor_idx, editor, buffer, row, col)
2887
-        call update_viewport(editor)
2888
-    end subroutine handle_mouse_click
2889
-
28902780
     subroutine select_next_match(editor, buffer)
28912781
         type(editor_state_t), intent(inout) :: editor
28922782
         type(buffer_t), intent(inout) :: buffer
@@ -3196,9 +3086,8 @@ contains
31963086
     ! Multiple Cursor Addition Above/Below
31973087
     ! ========================================================================
31983088
 
3199
-    subroutine add_cursor_above(editor, buffer)
3089
+    subroutine add_cursor_above(editor)
32003090
         type(editor_state_t), intent(inout) :: editor
3201
-        type(buffer_t), intent(in) :: buffer
32023091
         type(cursor_t), allocatable :: new_cursors(:)
32033092
         type(cursor_t) :: active_cursor
32043093
         integer :: i, new_line
@@ -3292,10 +3181,9 @@ contains
32923181
     ! Selection Extension Subroutines
32933182
     ! ========================================================================
32943183
 
3295
-    subroutine extend_selection_up(cursor, buffer, line_count)
3184
+    subroutine extend_selection_up(cursor, buffer)
32963185
         type(cursor_t), intent(inout) :: cursor
32973186
         type(buffer_t), intent(in) :: buffer
3298
-        integer, intent(in) :: line_count
32993187
         character(len=:), allocatable :: current_line, target_line
33003188
 
33013189
         ! Initialize selection if not already started
@@ -3450,10 +3338,9 @@ contains
34503338
         if (allocated(line)) deallocate(line)
34513339
     end subroutine extend_selection_end
34523340
 
3453
-    subroutine extend_selection_page_up(cursor, editor, line_count)
3341
+    subroutine extend_selection_page_up(cursor, editor)
34543342
         type(cursor_t), intent(inout) :: cursor
34553343
         type(editor_state_t), intent(in) :: editor
3456
-        integer, intent(in) :: line_count
34573344
         integer :: page_size
34583345
 
34593346
         ! Initialize selection if not already started
@@ -3491,7 +3378,6 @@ contains
34913378
         type(buffer_t), intent(in) :: buffer
34923379
         character(len=:), allocatable :: line
34933380
         integer :: pos, line_len
3494
-        logical :: in_word
34953381
 
34963382
         ! Initialize selection if not already started
34973383
         if (.not. cursor%has_selection) then
@@ -3565,7 +3451,6 @@ contains
35653451
         type(buffer_t), intent(in) :: buffer
35663452
         character(len=:), allocatable :: line
35673453
         integer :: pos, line_count, line_len
3568
-        logical :: in_word
35693454
 
35703455
         ! Initialize selection if not already started
35713456
         if (.not. cursor%has_selection) then
@@ -3747,49 +3632,6 @@ contains
37473632
     ! Character Transpose Subroutine
37483633
     ! ========================================================================
37493634
 
3750
-    subroutine transpose_characters(cursor, buffer)
3751
-        type(cursor_t), intent(inout) :: cursor
3752
-        type(buffer_t), intent(inout) :: buffer
3753
-        character(len=:), allocatable :: line
3754
-        character :: temp_char
3755
-        integer :: pos1, pos2
3756
-
3757
-        line = buffer_get_line(buffer, cursor%line)
3758
-
3759
-        if (cursor%column > 1 .and. cursor%column <= len(line) + 1) then
3760
-            if (cursor%column == len(line) + 1) then
3761
-                ! At end of line, swap last two characters
3762
-                pos1 = cursor%column - 2
3763
-                pos2 = cursor%column - 1
3764
-            else
3765
-                ! In middle of line, swap character before cursor with character at cursor
3766
-                pos1 = cursor%column - 1
3767
-                pos2 = cursor%column
3768
-            end if
3769
-
3770
-            if (pos1 >= 1 .and. pos2 <= len(line)) then
3771
-                ! Get the two characters
3772
-                temp_char = line(pos1:pos1)
3773
-
3774
-                ! Delete the first character
3775
-                call delete_range(buffer, cursor%line, pos1, cursor%line, pos1)
3776
-
3777
-                ! Insert it after the second position
3778
-                call insert_char_at(buffer, cursor%line, pos2, temp_char)
3779
-
3780
-                ! Move cursor forward if not at end of line
3781
-                if (cursor%column < len(line) + 1) then
3782
-                    cursor%column = cursor%column + 1
3783
-                    cursor%desired_column = cursor%column
3784
-                end if
3785
-
3786
-                buffer%modified = .true.
3787
-            end if
3788
-        end if
3789
-
3790
-        if (allocated(line)) deallocate(line)
3791
-    end subroutine transpose_characters
3792
-
37933635
     subroutine join_lines(cursor, buffer)
37943636
         type(cursor_t), intent(inout) :: cursor
37953637
         type(buffer_t), intent(inout) :: buffer
@@ -3903,7 +3745,7 @@ contains
39033745
         type(editor_state_t), intent(inout) :: editor
39043746
         type(buffer_t), intent(inout) :: buffer
39053747
         character(len=:), allocatable :: selected_path
3906
-        integer :: status, i
3748
+        integer :: i
39073749
 
39083750
         select case(trim(key_str))
39093751
         case('j', 'down')
src/terminal/input_handler_module.f90modified
@@ -213,7 +213,7 @@ contains
213213
                             end if
214214
                         case('1', '2', '4', '7', '8')
215215
                             ! ESC ESC [ 1 ; modifier format (Alt+Shift+arrow, etc)
216
-                            call handle_alt_modified_key(key_str, ch3)
216
+                            call handle_alt_modified_key(key_str)
217217
                         end select
218218
                     end if
219219
                 end if
@@ -416,9 +416,8 @@ contains
416416
         end select
417417
     end subroutine handle_alternate_modified_key
418418
 
419
-    subroutine handle_alt_modified_key(key_str, first_char)
419
+    subroutine handle_alt_modified_key(key_str)
420420
         character(len=*), intent(out) :: key_str
421
-        character, intent(in) :: first_char
422421
         character :: ch, terminator
423422
         character(len=10) :: modifier_seq
424423
         integer :: ios, modifier, char_code, read_count
src/terminal/renderer_module.f90modified
@@ -196,52 +196,6 @@ contains
196196
         end if
197197
     end subroutine render_screen
198198
 
199
-    subroutine render_line(buffer, line_num, start_col, width)
200
-        type(buffer_t), intent(in) :: buffer
201
-        integer, intent(in) :: line_num, start_col, width
202
-        character(len=:), allocatable :: line
203
-        character(len=:), allocatable :: visible_part
204
-        integer :: char_count, end_col
205
-        integer :: start_byte, end_byte, display_width
206
-
207
-        ! Get the line content
208
-        line = buffer_get_line(buffer, line_num)
209
-        char_count = utf8_char_count(line)
210
-
211
-        ! Calculate visible portion (start_col is character position)
212
-        if (start_col > char_count) then
213
-            ! Line is scrolled past its end
214
-            visible_part = repeat(' ', width)
215
-        else
216
-            end_col = min(start_col + width - 1, char_count)
217
-            if (end_col >= start_col) then
218
-                ! Convert character positions to byte positions
219
-                start_byte = utf8_char_to_byte_index(line, start_col)
220
-                end_byte = utf8_char_to_byte_index(line, end_col + 1) - 1
221
-
222
-                if (start_byte > 0 .and. end_byte >= start_byte .and. end_byte <= len(line)) then
223
-                    visible_part = line(start_byte:end_byte)
224
-                    display_width = utf8_display_width(visible_part)
225
-
226
-                    ! Pad with spaces if needed
227
-                    if (display_width < width) then
228
-                        visible_part = visible_part // repeat(' ', width - display_width)
229
-                    end if
230
-                else
231
-                    visible_part = repeat(' ', width)
232
-                end if
233
-            else
234
-                visible_part = repeat(' ', width)
235
-            end if
236
-        end if
237
-
238
-        ! Write the visible part
239
-        call terminal_write(visible_part)
240
-
241
-        if (allocated(line)) deallocate(line)
242
-        if (allocated(visible_part)) deallocate(visible_part)
243
-    end subroutine render_line
244
-
245199
     subroutine render_line_with_selections(buffer, editor, line_num, start_col, width)
246200
         type(buffer_t), intent(in) :: buffer
247201
         type(editor_state_t), intent(in) :: editor
@@ -760,7 +714,7 @@ contains
760714
             editor%tabs(tab_idx)%panes(i)%screen_height = pane_height
761715
 
762716
             ! Render the pane content
763
-            call render_single_pane(buffer, editor, i, pane_col, pane_row, pane_width, pane_height)
717
+            call render_single_pane(editor, i, pane_col, pane_row, pane_width, pane_height)
764718
 
765719
             ! Draw vertical separator between panes
766720
             if (i < n_panes) then
@@ -930,7 +884,7 @@ contains
930884
             editor%tabs(tab_idx)%panes(i)%screen_height = pane_height
931885
 
932886
             ! Render the pane content
933
-            call render_single_pane(buffer, editor, i, pane_col, pane_row, pane_width, pane_height)
887
+            call render_single_pane(editor, i, pane_col, pane_row, pane_width, pane_height)
934888
 
935889
             ! Draw vertical separator between panes
936890
             if (i < n_panes) then
@@ -939,9 +893,8 @@ contains
939893
         end do
940894
     end subroutine render_all_panes
941895
 
942
-    subroutine render_single_pane(buffer, editor, pane_idx, col, row, width, height)
896
+    subroutine render_single_pane(editor, pane_idx, col, row, width, height)
943897
         use editor_state_module, only: pane_t
944
-        type(buffer_t), intent(in) :: buffer
945898
         type(editor_state_t), intent(in) :: editor
946899
         integer, intent(in) :: pane_idx, col, row, width, height
947900
         type(pane_t) :: pane
src/ui/help_display_module.f90modified
@@ -258,31 +258,6 @@ contains
258258
         end do
259259
     end subroutine display_help_viewport
260260
 
261
-    subroutine display_section(row, max_rows, title, items)
262
-        integer, intent(inout) :: row
263
-        integer, intent(in) :: max_rows
264
-        character(len=*), intent(in) :: title
265
-        character(len=*), dimension(:), intent(in) :: items
266
-        integer :: i
267
-
268
-        if (row >= max_rows - 2) return
269
-
270
-        ! Section title
271
-        call terminal_move_cursor(row, 1)
272
-        call terminal_write(title)
273
-        row = row + 1
274
-
275
-        ! Section items
276
-        do i = 1, size(items)
277
-            if (row >= max_rows - 2) return
278
-            call terminal_move_cursor(row, 3)
279
-            call terminal_write(items(i))
280
-            row = row + 1
281
-        end do
282
-
283
-        row = row + 1  ! Extra space between sections
284
-    end subroutine display_section
285
-
286261
     subroutine show_tags_modal(editor, tags, n_tags)
287262
         type(editor_state_t), intent(in) :: editor
288263
         character(len=256), intent(in) :: tags(:)
src/workspace/file_tree_module.f90modified
@@ -218,7 +218,7 @@ contains
218218
         integer, intent(out) :: n_files
219219
         integer :: iostat, unit_num, status_code
220220
         character(len=1024) :: line, cmd
221
-        character(len=512) :: file_path
221
+        character(len=1024) :: file_path
222222
         integer :: max_files
223223
         type(file_entry_t), allocatable :: temp_files(:)
224224
 
@@ -522,7 +522,7 @@ contains
522522
 
523523
         if (.not. associated(node)) return
524524
 
525
-        write(unit, '(A,A,A,L,A,L)') trim(prefix), trim(node%name), &
525
+        write(unit, '(A,A,A,L1,A,L1)') trim(prefix), trim(node%name), &
526526
             ' is_file=', node%is_file, ' has_next_sib=', associated(node%next_sibling)
527527
 
528528
         child => node%first_child