prompt user to push a tag
- SHA
c04bdad3e1486bdfde8d7a27eec1ccde03de97c7- Parents
-
a661cb9 - Tree
b5979db
c04bdad
c04bdad3e1486bdfde8d7a27eec1ccde03de97c7a661cb9
b5979db| Status | File | + | - |
|---|---|---|---|
| M |
src/commands/command_handler_module.f90
|
5 | 5 |
| M |
src/ui/text_prompt_module.f90
|
45 | 1 |
src/commands/command_handler_module.f90modified@@ -16,7 +16,7 @@ module command_handler_module | ||
| 16 | 16 | use bracket_matching_module, only: find_matching_bracket |
| 17 | 17 | use file_tree_module |
| 18 | 18 | use git_ops_module |
| 19 | - use text_prompt_module, only: show_text_prompt | |
| 19 | + use text_prompt_module, only: show_text_prompt, show_yes_no_prompt | |
| 20 | 20 | implicit none |
| 21 | 21 | private |
| 22 | 22 | |
@@ -3939,7 +3939,7 @@ contains | ||
| 3939 | 3939 | character(len=256) :: tag_name, tag_message |
| 3940 | 3940 | character(len=256), allocatable :: existing_tags(:) |
| 3941 | 3941 | integer :: n_tags |
| 3942 | - logical :: cancelled, success | |
| 3942 | + logical :: cancelled, success, push_tag | |
| 3943 | 3943 | |
| 3944 | 3944 | ! Fetch and display existing tags (keeps them visible during prompts) |
| 3945 | 3945 | call git_list_tags(editor%workspace_path, existing_tags, n_tags) |
@@ -3967,10 +3967,10 @@ contains | ||
| 3967 | 3967 | ! Brief pause |
| 3968 | 3968 | call execute_command_line('sleep 1') |
| 3969 | 3969 | |
| 3970 | - ! Ask if user wants to push the tag to origin | |
| 3971 | - call show_text_prompt('Push tag to origin? (y/n, ESC to skip): ', tag_message, cancelled, editor%screen_rows) | |
| 3970 | + ! Ask if user wants to push the tag to origin (auto-submit on y/n) | |
| 3971 | + call show_yes_no_prompt('Push tag to origin? (y/n, ESC to skip): ', push_tag, cancelled, editor%screen_rows) | |
| 3972 | 3972 | |
| 3973 | - if (.not. cancelled .and. (tag_message(1:1) == 'y' .or. tag_message(1:1) == 'Y')) then | |
| 3973 | + if (.not. cancelled .and. push_tag) then | |
| 3974 | 3974 | call git_push_tag(editor%workspace_path, tag_name, success) |
| 3975 | 3975 | |
| 3976 | 3976 | ! Show push result |
src/ui/text_prompt_module.f90modified@@ -4,7 +4,7 @@ module text_prompt_module | ||
| 4 | 4 | implicit none |
| 5 | 5 | private |
| 6 | 6 | |
| 7 | - public :: show_text_prompt | |
| 7 | + public :: show_text_prompt, show_yes_no_prompt | |
| 8 | 8 | |
| 9 | 9 | contains |
| 10 | 10 | |
@@ -67,4 +67,48 @@ contains | ||
| 67 | 67 | call terminal_hide_cursor() |
| 68 | 68 | end subroutine show_text_prompt |
| 69 | 69 | |
| 70 | + subroutine show_yes_no_prompt(prompt_text, answer, cancelled, screen_rows) | |
| 71 | + character(len=*), intent(in) :: prompt_text | |
| 72 | + logical, intent(out) :: answer | |
| 73 | + logical, intent(out) :: cancelled | |
| 74 | + integer(int32), intent(in) :: screen_rows | |
| 75 | + integer :: ch | |
| 76 | + | |
| 77 | + ! Initialize | |
| 78 | + cancelled = .false. | |
| 79 | + answer = .false. | |
| 80 | + | |
| 81 | + ! Display prompt at bottom of screen | |
| 82 | + call terminal_move_cursor(screen_rows, 1) | |
| 83 | + call terminal_write(achar(27) // '[2K') ! Clear entire line | |
| 84 | + call terminal_move_cursor(screen_rows, 1) | |
| 85 | + call terminal_write(trim(prompt_text)) | |
| 86 | + call terminal_show_cursor() | |
| 87 | + | |
| 88 | + ! Input loop - wait for single y/n/esc keypress | |
| 89 | + do | |
| 90 | + ch = terminal_read_char() | |
| 91 | + | |
| 92 | + if (ch == -1) then | |
| 93 | + ! No input, continue | |
| 94 | + cycle | |
| 95 | + else if (ch == 27) then ! ESC | |
| 96 | + ! Cancel | |
| 97 | + cancelled = .true. | |
| 98 | + exit | |
| 99 | + else if (ch == 121 .or. ch == 89) then ! 'y' or 'Y' | |
| 100 | + ! Yes | |
| 101 | + answer = .true. | |
| 102 | + exit | |
| 103 | + else if (ch == 110 .or. ch == 78) then ! 'n' or 'N' | |
| 104 | + ! No | |
| 105 | + answer = .false. | |
| 106 | + exit | |
| 107 | + end if | |
| 108 | + ! Ignore other characters, keep waiting for y/n/esc | |
| 109 | + end do | |
| 110 | + | |
| 111 | + call terminal_hide_cursor() | |
| 112 | + end subroutine show_yes_no_prompt | |
| 113 | + | |
| 70 | 114 | end module text_prompt_module |