sanitize filenames

This commit is contained in:
Dylan Araps committed 2020-08-04 12:04:15 +03:00
1 parent adf86c3e2b
commit 40c1eab513
2 files changed
+22 -3

No files matched your search

+1 -1
View File
@@ -36,7 +36,7 @@ q - quit
todo todo
________________________________________________________________________________ ________________________________________________________________________________
- [ ] sanitize filenames for display. - [x] sanitize filenames for display.
- [ ] fix buggy focus after exit from inline editor. - [ ] fix buggy focus after exit from inline editor.
- [ ] maybe file operations. - [ ] maybe file operations.
- [ ] add / to directories. - [ ] add / to directories.
+21 -2
View File
@@ -24,6 +24,22 @@ term_resize() {
bottom=$((LINES - 2)) bottom=$((LINES - 2))
} }
file_escape() {
tmp=$1 safe=
# loop over string char by char
while [ "$tmp" ]; do
c=${tmp%"${tmp#?}"*}
case $c in
[[:print:]]) safe=$safe$c ;;
*) safe=$safe\? ;;
esac
tmp=${tmp#?}
done
}
hist_search() { hist_search() {
hist=0 j=1 hist=0 j=1
@@ -51,12 +67,14 @@ list_print() {
esac esac
for file do for file do
file_escape "$file"
case $i in case $i in
"$y2") printf '\033[34;7m' "$y2") printf '\033[34;7m'
esac esac
case $((i - end)) in case $((i - end)) in
-*) printf '%s\033[m\033[B\r' "$file" -*) printf '%s\033[m\033[B\r' "$safe"
esac esac
i=$((i + 1)) i=$((i + 1))
@@ -98,7 +116,8 @@ print_line() {
esac esac
shift "$offset" shift "$offset"
printf '\033[K%s\033[m\r' "$1" file_escape "$1"
printf '\033[K%s\033[m\r' "$safe"
case $offset in case $offset in
"$y") cur=$1 "$y") cur=$1