@@ -257,7 +257,7 @@ contains |
| 257 | 257 | |
| 258 | 258 | ! Selection with shift+motion |
| 259 | 259 | 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) |
| 261 | 261 | call sync_editor_to_pane(editor) |
| 262 | 262 | call update_viewport(editor) |
| 263 | 263 | |
@@ -314,10 +314,10 @@ contains |
| 314 | 314 | if (size(editor%cursors) > 1) then |
| 315 | 315 | ! Move all cursors |
| 316 | 316 | 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) |
| 318 | 318 | end do |
| 319 | 319 | 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) |
| 321 | 321 | end if |
| 322 | 322 | call sync_editor_to_pane(editor) |
| 323 | 323 | call update_viewport(editor) |
@@ -363,7 +363,7 @@ contains |
| 363 | 363 | call update_viewport(editor) |
| 364 | 364 | |
| 365 | 365 | 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) |
| 367 | 367 | call sync_editor_to_pane(editor) |
| 368 | 368 | call update_viewport(editor) |
| 369 | 369 | |
@@ -841,7 +841,7 @@ contains |
| 841 | 841 | ! Add cursor on line above |
| 842 | 842 | ! opt-meta-up: Doesn't work (terminals don't send Cmd) |
| 843 | 843 | ! ctrl-alt-up: Alternative binding that works |
| 844 | | - call add_cursor_above(editor, buffer) |
| 844 | + call add_cursor_above(editor) |
| 845 | 845 | call sync_editor_to_pane(editor) |
| 846 | 846 | call update_viewport(editor) |
| 847 | 847 | |
@@ -1101,10 +1101,9 @@ contains |
| 1101 | 1101 | if (allocated(line)) deallocate(line) |
| 1102 | 1102 | end subroutine move_cursor_end |
| 1103 | 1103 | |
| 1104 | | - subroutine move_cursor_page_up(cursor, editor, line_count) |
| 1104 | + subroutine move_cursor_page_up(cursor, editor) |
| 1105 | 1105 | type(cursor_t), intent(inout) :: cursor |
| 1106 | 1106 | type(editor_state_t), intent(in) :: editor |
| 1107 | | - integer, intent(in) :: line_count |
| 1108 | 1107 | integer :: page_size |
| 1109 | 1108 | |
| 1110 | 1109 | cursor%has_selection = .false. ! Clear selection |
@@ -1130,7 +1129,6 @@ contains |
| 1130 | 1129 | type(buffer_t), intent(in) :: buffer |
| 1131 | 1130 | character(len=:), allocatable :: line |
| 1132 | 1131 | integer :: pos, line_len |
| 1133 | | - logical :: in_word |
| 1134 | 1132 | |
| 1135 | 1133 | cursor%has_selection = .false. ! Clear selection |
| 1136 | 1134 | line = buffer_get_line(buffer, cursor%line) |
@@ -1201,7 +1199,6 @@ contains |
| 1201 | 1199 | type(buffer_t), intent(in) :: buffer |
| 1202 | 1200 | character(len=:), allocatable :: line |
| 1203 | 1201 | integer :: pos, line_count, line_len |
| 1204 | | - logical :: in_word |
| 1205 | 1202 | |
| 1206 | 1203 | cursor%has_selection = .false. ! Clear selection |
| 1207 | 1204 | line = buffer_get_line(buffer, cursor%line) |
@@ -1574,7 +1571,6 @@ contains |
| 1574 | 1571 | character, intent(in) :: ch |
| 1575 | 1572 | integer :: i |
| 1576 | 1573 | integer :: offset_adjust |
| 1577 | | - integer :: cursors_before |
| 1578 | 1574 | |
| 1579 | 1575 | ! Sort cursors by position to handle offset adjustments |
| 1580 | 1576 | call sort_cursors_by_position(editor) |
@@ -2161,39 +2157,6 @@ contains |
| 2161 | 2157 | end do |
| 2162 | 2158 | end subroutine insert_line_text |
| 2163 | 2159 | |
| 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 | | - |
| 2197 | 2160 | function buffer_get_char_at(buffer, pos) result(ch) |
| 2198 | 2161 | type(buffer_t), intent(in) :: buffer |
| 2199 | 2162 | integer, intent(in) :: pos |
@@ -2289,10 +2252,9 @@ contains |
| 2289 | 2252 | subroutine save_file(editor, buffer) |
| 2290 | 2253 | type(editor_state_t), intent(in) :: editor |
| 2291 | 2254 | type(buffer_t), intent(inout) :: buffer |
| 2292 | | - integer :: ios, temp_unit |
| 2255 | + integer :: ios |
| 2293 | 2256 | character(len=256) :: temp_filename, command |
| 2294 | | - character(len=1024) :: error_msg |
| 2295 | | - logical :: file_exists, has_write_permission |
| 2257 | + logical :: file_exists |
| 2296 | 2258 | |
| 2297 | 2259 | if (.not. allocated(editor%filename)) return |
| 2298 | 2260 | |
@@ -2315,7 +2277,7 @@ contains |
| 2315 | 2277 | inquire(file=editor%filename, exist=file_exists) |
| 2316 | 2278 | |
| 2317 | 2279 | ! 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() |
| 2319 | 2281 | |
| 2320 | 2282 | ! Save to temporary file |
| 2321 | 2283 | call buffer_save_file(buffer, temp_filename, ios) |
@@ -2349,7 +2311,7 @@ contains |
| 2349 | 2311 | end if |
| 2350 | 2312 | end subroutine save_file |
| 2351 | 2313 | |
| 2352 | | - function getpid() result(pid) |
| 2314 | + function get_process_id() result(pid) |
| 2353 | 2315 | integer :: pid |
| 2354 | 2316 | interface |
| 2355 | 2317 | function c_getpid() bind(C, name="getpid") |
@@ -2358,7 +2320,7 @@ contains |
| 2358 | 2320 | end function |
| 2359 | 2321 | end interface |
| 2360 | 2322 | pid = c_getpid() |
| 2361 | | - end function getpid |
| 2323 | + end function get_process_id |
| 2362 | 2324 | |
| 2363 | 2325 | subroutine cycle_quotes(cursor, buffer) |
| 2364 | 2326 | type(cursor_t), intent(inout) :: cursor |
@@ -2524,7 +2486,6 @@ contains |
| 2524 | 2486 | integer :: colon1, colon2, colon3 |
| 2525 | 2487 | character(len=100) :: event_type |
| 2526 | 2488 | integer :: ios, line_count |
| 2527 | | - logical :: is_alt_click |
| 2528 | 2489 | type(cursor_t), allocatable :: new_cursors(:) |
| 2529 | 2490 | integer :: i, cursor_exists |
| 2530 | 2491 | ! Variables for mouse drag handling |
@@ -2816,77 +2777,6 @@ contains |
| 2816 | 2777 | at_pos = (cursor_screen_row == screen_row .and. cursor_screen_col == screen_col) |
| 2817 | 2778 | end function is_cursor_at_screen_pos |
| 2818 | 2779 | |
| 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 | | - |
| 2890 | 2780 | subroutine select_next_match(editor, buffer) |
| 2891 | 2781 | type(editor_state_t), intent(inout) :: editor |
| 2892 | 2782 | type(buffer_t), intent(inout) :: buffer |
@@ -3196,9 +3086,8 @@ contains |
| 3196 | 3086 | ! Multiple Cursor Addition Above/Below |
| 3197 | 3087 | ! ======================================================================== |
| 3198 | 3088 | |
| 3199 | | - subroutine add_cursor_above(editor, buffer) |
| 3089 | + subroutine add_cursor_above(editor) |
| 3200 | 3090 | type(editor_state_t), intent(inout) :: editor |
| 3201 | | - type(buffer_t), intent(in) :: buffer |
| 3202 | 3091 | type(cursor_t), allocatable :: new_cursors(:) |
| 3203 | 3092 | type(cursor_t) :: active_cursor |
| 3204 | 3093 | integer :: i, new_line |
@@ -3292,10 +3181,9 @@ contains |
| 3292 | 3181 | ! Selection Extension Subroutines |
| 3293 | 3182 | ! ======================================================================== |
| 3294 | 3183 | |
| 3295 | | - subroutine extend_selection_up(cursor, buffer, line_count) |
| 3184 | + subroutine extend_selection_up(cursor, buffer) |
| 3296 | 3185 | type(cursor_t), intent(inout) :: cursor |
| 3297 | 3186 | type(buffer_t), intent(in) :: buffer |
| 3298 | | - integer, intent(in) :: line_count |
| 3299 | 3187 | character(len=:), allocatable :: current_line, target_line |
| 3300 | 3188 | |
| 3301 | 3189 | ! Initialize selection if not already started |
@@ -3450,10 +3338,9 @@ contains |
| 3450 | 3338 | if (allocated(line)) deallocate(line) |
| 3451 | 3339 | end subroutine extend_selection_end |
| 3452 | 3340 | |
| 3453 | | - subroutine extend_selection_page_up(cursor, editor, line_count) |
| 3341 | + subroutine extend_selection_page_up(cursor, editor) |
| 3454 | 3342 | type(cursor_t), intent(inout) :: cursor |
| 3455 | 3343 | type(editor_state_t), intent(in) :: editor |
| 3456 | | - integer, intent(in) :: line_count |
| 3457 | 3344 | integer :: page_size |
| 3458 | 3345 | |
| 3459 | 3346 | ! Initialize selection if not already started |
@@ -3491,7 +3378,6 @@ contains |
| 3491 | 3378 | type(buffer_t), intent(in) :: buffer |
| 3492 | 3379 | character(len=:), allocatable :: line |
| 3493 | 3380 | integer :: pos, line_len |
| 3494 | | - logical :: in_word |
| 3495 | 3381 | |
| 3496 | 3382 | ! Initialize selection if not already started |
| 3497 | 3383 | if (.not. cursor%has_selection) then |
@@ -3565,7 +3451,6 @@ contains |
| 3565 | 3451 | type(buffer_t), intent(in) :: buffer |
| 3566 | 3452 | character(len=:), allocatable :: line |
| 3567 | 3453 | integer :: pos, line_count, line_len |
| 3568 | | - logical :: in_word |
| 3569 | 3454 | |
| 3570 | 3455 | ! Initialize selection if not already started |
| 3571 | 3456 | if (.not. cursor%has_selection) then |
@@ -3747,49 +3632,6 @@ contains |
| 3747 | 3632 | ! Character Transpose Subroutine |
| 3748 | 3633 | ! ======================================================================== |
| 3749 | 3634 | |
| 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 | | - |
| 3793 | 3635 | subroutine join_lines(cursor, buffer) |
| 3794 | 3636 | type(cursor_t), intent(inout) :: cursor |
| 3795 | 3637 | type(buffer_t), intent(inout) :: buffer |
@@ -3903,7 +3745,7 @@ contains |
| 3903 | 3745 | type(editor_state_t), intent(inout) :: editor |
| 3904 | 3746 | type(buffer_t), intent(inout) :: buffer |
| 3905 | 3747 | character(len=:), allocatable :: selected_path |
| 3906 | | - integer :: status, i |
| 3748 | + integer :: i |
| 3907 | 3749 | |
| 3908 | 3750 | select case(trim(key_str)) |
| 3909 | 3751 | case('j', 'down') |