diff --git a/README.md b/README.md index 11a9fc8..77e157b 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,6 @@ Bopher-NG's mouse input is supported on any terminals that support the 1000 **an Note that this support is required at the client side only. For instance, you can safely run `bopher-ng.sh` on any compatible Bash version in an SSH session on your terminal and still be able to use mouse there. - ## What is the license on this? -Fully public domain +Fully public domain. diff --git a/bopher-ng.sh b/bopher-ng.sh index aad1a80..dcc4306 100755 --- a/bopher-ng.sh +++ b/bopher-ng.sh @@ -39,13 +39,14 @@ fi [[ -z "$BOPHER_DLDIR" ]] && BOPHER_DLDIR="$PWD" # downloads directory # styling used in the TUI -ESC="\x1b" +ESC=$'\x1b' # use the ANSI literal syntax to support in read prompts as well ERESET="$ESC[0m" # reset the styling ERRCOLOR="$ESC[31;1m" # red bold LINKCOLOR="$ESC[36;1m" # cyan bold FOCUSATTR="$ESC[7;2m" # swap foreground and background and brightness level CLS="$ESC[2J" # clear the entire screen CURRESET="$ESC[0;0H" # reset the visual cursor +CURSTART="$ESC[1G" # move cursor to the start of the line LINECLR="$ESC[2K" # clear current line BELOWCLR="$ESC[0J" # clear everything below ALTBUFON="$ESC[?47h" # use the alternative screen buffer @@ -117,24 +118,25 @@ amtogopher() { # args: AM line } # AM entry clicker function -amclick() { # args: AM line, output: AM line(s) +amclick() { # args: AM line[, forcedl], output: AM line(s) readarray -d $'\t' -t fields < <(printf '%s' "$1") local action="${fields[0]}" local desc="${fields[1]}" local rhost="${fields[2]}" local rport="${fields[3]}" local sel="${fields[4]}" + local input='' + if [[ 'I' == "$action" ]]; then + read -p "${LINECLR}${CURSTART}Enter input for $rhost: " input + fi + [[ ! -z "$2" ]] && action='D' # force the download action if [[ 'D' == "$action" ]]; then # download local fname="${sel##*/}" # pure-bash version of basename [[ -z "$fname" ]] && fname='dl.dat' # just make sure that it's not empty - gophetch "$rhost" "$rport" "$sel" > "$BOPHER_DLDIR/$fname" + [[ ! -z "$input" ]] && fname="${fname}%09${input}.search.txt" + gophetch "$rhost" "$rport" "$sel" "$input" > "$BOPHER_DLDIR/$fname" printf 'E\tDownloaded %s to %s\n' "$(amtogopher "$1")" "$BOPHER_DLDIR/$fname" elif [[ 'I' == "$action" || 'M' == "$action" || 'P' == "$action" ]]; then # text content - local input='' - if [[ 'I' == "$action" ]]; then - printf '%b' "$LINECLR" # clear the current line on the terminal - read -p "Enter input for $rhost: " input - fi readarray -t lines < <(gophetch "$rhost" "$rport" "$sel" "$input") for line in "${lines[@]}"; do # iterate over every fetched line if [[ 'P' == "$action" ]]; then # generate a plaintext AM entry @@ -216,8 +218,7 @@ jumplink() { # args: delta (usually 1 or -1) amload() { # args: AM line[, forcedl] CURRENTAM="$1" # update current AM value printf '%b' "${LINECLR}Loading..." - [[ ! -z "$2" ]] && CURRENTAM="D${CURRENTAM:1}" # modify CURRENTAM first char to the download type - readarray -t SCREENBUF < <(amclick "$CURRENTAM") # populate screen buffer by loading the resource from the AM entry + readarray -t SCREENBUF < <(amclick "$CURRENTAM" "$2") # populate screen buffer by loading the resource from the AM entry NAVIGABLES=() # reset the navigable indexes CURLINKINDEX=0 # reset the link number CURSCROLLPOS=0 # reset the scrolling position