improve rename mode
This commit is contained in:
@@ -777,8 +777,10 @@ open_file() {
|
|||||||
# read a line of input in raw mode, returns result in READ_LINE
|
# read a line of input in raw mode, returns result in READ_LINE
|
||||||
# returns 1 if user pressed Esc (cancel), 0 on Enter
|
# returns 1 if user pressed Esc (cancel), 0 on Enter
|
||||||
read_line() {
|
read_line() {
|
||||||
READ_LINE=""
|
READ_LINE="${_init:-}"
|
||||||
|
_init=""
|
||||||
show_cursor
|
show_cursor
|
||||||
|
printf '%s' "$READ_LINE"
|
||||||
while true; do
|
while true; do
|
||||||
IFS= read -r -n1 _ch 2>/dev/null || IFS= read -r _ch
|
IFS= read -r -n1 _ch 2>/dev/null || IFS= read -r _ch
|
||||||
case "$_ch" in
|
case "$_ch" in
|
||||||
@@ -1351,10 +1353,11 @@ do_delete() {
|
|||||||
|
|
||||||
do_rename() {
|
do_rename() {
|
||||||
entry=$(get_entry "$SEL")
|
entry=$(get_entry "$SEL")
|
||||||
goto "$(term_rows)" 1
|
|
||||||
printf '%s%s Rename "%s" to (esc=cancel): %s' "${ERASE_LINE}" "${YELLOW}${BOLD}" "$entry" "${RESET}"
|
|
||||||
if read_line && [ -n "$READ_LINE" ] && [ "$READ_LINE" != "$entry" ]; then
|
|
||||||
_name="${entry%@}"; _name="${_name%/}"
|
_name="${entry%@}"; _name="${_name%/}"
|
||||||
|
goto "$(term_rows)" 1
|
||||||
|
printf '%s%s Rename: %s' "${ERASE_LINE}" "${YELLOW}${BOLD}" "${RESET}"
|
||||||
|
_init="$_name"
|
||||||
|
if read_line && [ -n "$READ_LINE" ] && [ "$READ_LINE" != "$_name" ]; then
|
||||||
mv "${CWD}/${_name}" "${CWD}/${READ_LINE}"
|
mv "${CWD}/${_name}" "${CWD}/${READ_LINE}"
|
||||||
load_entries
|
load_entries
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user