mirror of
https://github.com/rworkman/slackpkg
synced 2025-01-22 19:27:14 +01:00
new-config dialog
One extra prompt at end to stop file list flying off top of screen. Calculate lines in K/O/R/P prompt before printing it, and use it to work out screen MAXROWS etc.
This commit is contained in:
parent
fe99f902eb
commit
19c9fc0d9b
1 changed files with 79 additions and 41 deletions
|
@ -124,6 +124,10 @@ runvimdiff() {
|
||||||
}
|
}
|
||||||
|
|
||||||
looknew() {
|
looknew() {
|
||||||
|
local ROWS SIZE FILES PROMPTTEXT TEXTLINES MAXROWS
|
||||||
|
local newcount f n fn
|
||||||
|
f=0
|
||||||
|
n=0
|
||||||
|
|
||||||
# with ONLY_NEW_DOTNEW set, slackpkg will search only for
|
# with ONLY_NEW_DOTNEW set, slackpkg will search only for
|
||||||
# .new files installed in actual slackpkg's execution
|
# .new files installed in actual slackpkg's execution
|
||||||
|
@ -133,10 +137,6 @@ looknew() {
|
||||||
ONLY_NEW_DOTNEW=""
|
ONLY_NEW_DOTNEW=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SIZE=$( stty size )
|
|
||||||
ROWS=${SIZE% *}
|
|
||||||
LISTMAX=$(( ROWS - 10 ))
|
|
||||||
|
|
||||||
printf "%s\n" "Searching for NEW configuration files..."
|
printf "%s\n" "Searching for NEW configuration files..."
|
||||||
|
|
||||||
FILES=$( find \
|
FILES=$( find \
|
||||||
|
@ -154,25 +154,65 @@ looknew() {
|
||||||
|
|
||||||
if [ -n "$FILES" ]; then
|
if [ -n "$FILES" ]; then
|
||||||
newcount=$( echo "$FILES" | wc -l )
|
newcount=$( echo "$FILES" | wc -l )
|
||||||
|
SIZE=$( stty size )
|
||||||
|
ROWS=${SIZE% *}
|
||||||
|
|
||||||
|
# Set here so we can count the No. of lines
|
||||||
|
PROMPTTEXT="\n\
|
||||||
|
What do you want (K/O/R/P)?
|
||||||
|
|
||||||
|
(K)eep the old files and consider .new files later
|
||||||
|
|
||||||
|
(O)verwrite all old files with the new ones"
|
||||||
|
|
||||||
|
[ "$ORIG_BACKUPS" != "off" ] && PROMPTTEXT+=". The
|
||||||
|
old files will be stored with the suffix .orig"
|
||||||
|
|
||||||
|
PROMPTTEXT+="\n\n\
|
||||||
|
(R)emove all .new files
|
||||||
|
|
||||||
|
(P)rompt K, O, R selection for every single file\n"
|
||||||
|
|
||||||
printf "%s %s\n\n" "Some packages had new configuration" \
|
printf "%s %s\n\n" "Some packages had new configuration" \
|
||||||
"files installed ($newcount new files):"
|
"files installed ($newcount new files):"
|
||||||
|
|
||||||
if [ $newcount -le $LISTMAX ]; then
|
# No. of prompt etc. lines to print.
|
||||||
echo "$FILES"
|
TEXTLINES=$(( $( printf %b "$PROMPTTEXT" | wc -l ) + 3 ))
|
||||||
else
|
|
||||||
F=0
|
|
||||||
N=0
|
|
||||||
for FN in $FILES; do
|
|
||||||
F=$(( F + 1 ))
|
|
||||||
N=$(( N + 1 ))
|
|
||||||
echo "$N $FN"
|
|
||||||
|
|
||||||
if [ $F -ge $(( ROWS - 5 )) ]; then
|
if [ $(( newcount + TEXTLINES )) -lt $ROWS ]; then
|
||||||
F=0
|
# All files will fit on screen.
|
||||||
IFS=$( printf "\n" ) read -rn 1 \
|
printf "%s\n" "$FILES"
|
||||||
-p "
|
else
|
||||||
Press SPACE for more, ENTER to skip" junk
|
# Won't all fit, so scroll a screenfull at a time.
|
||||||
|
# No. of lines minus 'Searching for' + 'Press SPACE...'
|
||||||
|
MAXROWS=$(( ROWS - 5 ))
|
||||||
|
|
||||||
|
for fn in $FILES; do
|
||||||
|
junk=" "
|
||||||
|
f=$(( f + 1 ))
|
||||||
|
n=$(( n + 1 ))
|
||||||
|
echo "$fn"
|
||||||
|
|
||||||
|
# Stop printing at bottom of screen
|
||||||
|
if [ $f -ge $MAXROWS ]; then
|
||||||
|
|
||||||
|
# No. of lines minus 'Press SPACE...'
|
||||||
|
MAXROWS=$(( ROWS - 2 ))
|
||||||
|
f=0
|
||||||
|
IFS=$( printf "\n" ) read -rn 1 -p "
|
||||||
|
Press SPACE for more, ENTER to skip" junk
|
||||||
|
|
||||||
|
# Enter pressed
|
||||||
|
if [ -z "$junk" ]; then
|
||||||
|
tput -S <<EOF
|
||||||
|
cuu 1
|
||||||
|
el 2
|
||||||
|
cuu 1
|
||||||
|
el 2
|
||||||
|
EOF
|
||||||
|
break
|
||||||
|
else
|
||||||
|
# Space pressed
|
||||||
printf "\n"
|
printf "\n"
|
||||||
tput -S <<EOF
|
tput -S <<EOF
|
||||||
cuu 1
|
cuu 1
|
||||||
|
@ -180,27 +220,25 @@ Press SPACE for more, ENTER to skip" junk
|
||||||
cuu 1
|
cuu 1
|
||||||
el 2
|
el 2
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if [ -z "$junk" ]; then
|
|
||||||
break
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Final prompt to stop list scrolling off the top
|
||||||
|
if [ ! -z "$junk" ] && [ $f -ne 0 ]; then
|
||||||
|
IFS=$( printf "\n" ) read -rn 1 -p "
|
||||||
|
Press any key to continue" junk
|
||||||
|
printf "\n"
|
||||||
|
tput -S <<EOF
|
||||||
|
cuu 1
|
||||||
|
el 2
|
||||||
|
cuu 1
|
||||||
|
el 2
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -ne "\n\
|
printf %b "$PROMPTTEXT"
|
||||||
What do you want (K/O/R/P)?
|
|
||||||
|
|
||||||
(K)eep the old files and consider .new files later
|
|
||||||
|
|
||||||
(O)verwrite all old files with the new ones"
|
|
||||||
[ "$ORIG_BACKUPS" != "off" ] && echo -ne ". The
|
|
||||||
old files will be stored with the suffix .orig"
|
|
||||||
echo -e "\n\n\
|
|
||||||
(R)emove all .new files
|
|
||||||
|
|
||||||
(P)rompt K, O, R selection for every single file"
|
|
||||||
|
|
||||||
answer
|
answer
|
||||||
case $ANSWER in
|
case $ANSWER in
|
||||||
K|k)
|
K|k)
|
||||||
|
|
Loading…
Add table
Reference in a new issue