8000 Change marking behavior to mark without operation. by dylanaraps · Pull Request #80 · dylanaraps/fff · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Change marking behavior to mark without operation. #80

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 39 additions & 16 deletions fff
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ get_ls_colors() {

status_line() {
# Status_line to print when files are marked for operation.
local mark_ui="[${#marked_files[@]}] selected (${file_program[*]}) [p] ->"
local mark_ui="[${#marked_files[@]}] selected "
mark_ui+="[${file_program[*]:-y,m,d,b,s}] [p] ->"

# Escape the directory string.
# Remove all non-printable characters.
Expand Down Expand Up @@ -336,6 +337,7 @@ mark() {
mark_dir="$PWD"
else
marked_files=()
file_program=()
fi

redraw
Expand All @@ -353,16 +355,9 @@ mark() {
print_line "$1"
fi

# Find the program to use.
case "$2" in
y|Y) file_program=(cp -iR) ;;
m|M) file_program=(mv -i) ;;
s|S) file_program=(ln -s) ;;

# These are 'fff' functions.
d|D) file_program=(trash) ;;
b|B) file_program=(bulk_rename) ;;
esac
# If no programs are marked, clear the type of operation.
[[ -z ${marked_files[*]} ]] &&
file_program=()

status_line
}
Expand Down Expand Up @@ -729,15 +724,36 @@ key() {
"${FFF_KEY_TRASH:=d}"|\
"${FFF_KEY_LINK:=s}"|\
"${FFF_KEY_BULK_RENAME:=b}")
[[ -z "${marked_files[*]}" ]] &&
return

previous_program="${file_program[0]}"

# Find the program to use.
case "$1" in
y) file_program=(cp -iR) ;;
m) file_program=(mv -i) ;;
s) file_program=(ln -s) ;;

# These are 'fff' functions.
d) file_program=(trash) ;;
b) file_program=(bulk_rename) ;;
esac

# Toggle the file progam if the same key was pressed.
[[ $previous_program == "${file_program[0]}" ]] &&
file_program=()

status_line
;;

# Mark files for operation.
"${FFF_KEY_MARK:=" "}")
mark "$scroll" "$1"
;;

# Mark all files for operation.
"${FFF_KEY_YANK_ALL:=Y}"|\
"${FFF_KEY_MOVE_ALL:=M}"|\
"${FFF_KEY_TRASH_ALL:=D}"|\
"${FFF_KEY_LINK_ALL:=S}"|\
"${FFF_KEY_BULK_RENAME_ALL:=B}")
"${FFF_KEY_MARK_ALL:=v}")
mark all "$1"
;;

Expand All @@ -749,6 +765,11 @@ key() {
return
}

[[ -z ${file_program[0]} ]] && {
cmd_line "warn: no operation selected [y,m,d,b,s]."
return
}

# Clear the screen to make room for a prompt if needed.
clear_screen
printf '\e[?25h'
Expand All @@ -759,6 +780,7 @@ key() {

printf '\e[?25l'
marked_files=()
file_program=()
redraw full
}
;;
Expand All @@ -767,6 +789,7 @@ key() {
"${FFF_KEY_CLEAR:=c}")
[[ ${marked_files[*]} ]] && {
marked_files=()
file_program=()
redraw
}
;;
Expand Down
0