fortrangoingonforty/facsimile / c04bdad

Browse files

prompt user to push a tag

Authored by espadonne
SHA
c04bdad3e1486bdfde8d7a27eec1ccde03de97c7
Parents
a661cb9
Tree
b5979db

2 changed files

StatusFile+-
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
1616
     use bracket_matching_module, only: find_matching_bracket
1717
     use file_tree_module
1818
     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
2020
     implicit none
2121
     private
2222
 
@@ -3939,7 +3939,7 @@ contains
39393939
         character(len=256) :: tag_name, tag_message
39403940
         character(len=256), allocatable :: existing_tags(:)
39413941
         integer :: n_tags
3942
-        logical :: cancelled, success
3942
+        logical :: cancelled, success, push_tag
39433943
 
39443944
         ! Fetch and display existing tags (keeps them visible during prompts)
39453945
         call git_list_tags(editor%workspace_path, existing_tags, n_tags)
@@ -3967,10 +3967,10 @@ contains
39673967
                     ! Brief pause
39683968
                     call execute_command_line('sleep 1')
39693969
 
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)
39723972
 
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
39743974
                         call git_push_tag(editor%workspace_path, tag_name, success)
39753975
 
39763976
                         ! Show push result
src/ui/text_prompt_module.f90modified
@@ -4,7 +4,7 @@ module text_prompt_module
44
     implicit none
55
     private
66
 
7
-    public :: show_text_prompt
7
+    public :: show_text_prompt, show_yes_no_prompt
88
 
99
 contains
1010
 
@@ -67,4 +67,48 @@ contains
6767
         call terminal_hide_cursor()
6868
     end subroutine show_text_prompt
6969
 
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
+
70114
 end module text_prompt_module