| 1 | module rename_prompt_module |
| 2 | use iso_fortran_env, only: int32 |
| 3 | use text_prompt_module, only: show_text_prompt |
| 4 | implicit none |
| 5 | private |
| 6 | |
| 7 | public :: show_rename_prompt |
| 8 | |
| 9 | contains |
| 10 | |
| 11 | subroutine show_rename_prompt(screen_rows, old_name, new_name, cancelled) |
| 12 | integer(int32), intent(in) :: screen_rows |
| 13 | character(len=*), intent(in) :: old_name |
| 14 | character(len=:), allocatable, intent(out) :: new_name |
| 15 | logical, intent(out) :: cancelled |
| 16 | |
| 17 | character(len=256) :: prompt_text |
| 18 | character(len=512) :: input_text |
| 19 | |
| 20 | ! Create prompt message with old name |
| 21 | write(prompt_text, '(A)') "Rename '" // trim(old_name) // "' to: " |
| 22 | |
| 23 | ! Show the text prompt |
| 24 | call show_text_prompt(trim(prompt_text), input_text, cancelled, screen_rows) |
| 25 | |
| 26 | if (.not. cancelled) then |
| 27 | if (len_trim(input_text) > 0 .and. trim(input_text) /= trim(old_name)) then |
| 28 | allocate(character(len=len_trim(input_text)) :: new_name) |
| 29 | new_name = trim(input_text) |
| 30 | else |
| 31 | cancelled = .true. |
| 32 | end if |
| 33 | end if |
| 34 | end subroutine show_rename_prompt |
| 35 | |
| 36 | end module rename_prompt_module |
| 37 |