From cf5bbfa32b3d396b471542d97d4920c083c6a538 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 30 May 2020 16:45:56 -0500 Subject: Change margin stuff --- bollux | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/bollux b/bollux index 6f121b0..c938abe 100755 --- a/bollux +++ b/bollux @@ -432,9 +432,9 @@ typeset_gemini() { log d "LINES=$LINES; COLUMNS=$COLUMNS" T_WIDTH=$COLUMNS fi - - WIDTH=$((T_WIDTH - (T_MARGIN * 2))) - ((WIDTH < 0)) && WIDTH=80 # default if dumb + WIDTH=$((T_WIDTH - T_MARGIN)) + ((WIDTH < 0)) && WIDTH=80 # default if dumb + S_MARGIN=$((T_MARGIN - 1)) # spacing log d "T_WIDTH=$T_WIDTH" log d "WIDTH=$WIDTH" @@ -454,7 +454,13 @@ typeset_gemini() { gemini_link "$REPLY" $pre "$ln" ;; \#*) gemini_header "$REPLY" $pre ;; - \**) gemini_list "$REPLY" $pre ;; + \**) + if [[ "$REPLY" =~ ^\*[[:space:]]+ ]]; then + gemini_list "$REPLY" $pre + else + gemini_text "$REPLY" $pre + fi + ;; *) gemini_text "$REPLY" $pre ;; esac done @@ -472,7 +478,7 @@ gemini_link() { a= fi - printf "\e[${C_SIGIL}m%-${T_MARGIN}s${C_RESET}" "$s" + printf "\e[${C_SIGIL}m%${S_MARGIN}s ${C_RESET}" "$s" printf -v l "\e[${C_LINK_NUMBER}m[%d]${C_RESET} \ \e[${C_LINK_TITLE}m%s${C_RESET} \ \e[${C_LINK_URL}m%s${C_RESET}\n" \ @@ -493,7 +499,7 @@ gemini_header() { local hdrfmt hdrfmt="$(eval echo "\$C_HEADER$a")" - printf "\e[${C_SIGIL}m%$((T_MARGIN - 1))s ${C_RESET}" "$s" + printf "\e[${C_SIGIL}m%${S_MARGIN}s ${C_RESET}" "$s" printf -v l "\e[${hdrfmt}m%s${C_RESET}\n" "$t" fold_line "$WIDTH" "$l" else @@ -508,7 +514,7 @@ gemini_list() { s="${BASH_REMATCH[1]}" t="${BASH_REMATCH[2]}" - printf "\e[${C_SIGIL}m%-${T_MARGIN}s" "$s" + printf "\e[${C_SIGIL}m%${S_MARGIN}s " "$s" printf -v l "\e[${C_LIST}m%s${C_RESET}\n" "$t" fold_line "$WIDTH" "$l" else @@ -518,7 +524,7 @@ gemini_list() { gemini_text() { if ! ${2-false}; then - printf "%${T_MARGIN}s" ' ' + printf "%${S_MARGIN}s " ' ' fold_line "$WIDTH" "$1" else gemini_pre "$1" @@ -526,7 +532,7 @@ gemini_text() { } gemini_pre() { - printf "\e[${C_SIGIL}m%-${T_MARGIN}s" '```' + printf "\e[${C_SIGIL}m%${S_MARGIN}s " '```' printf "\e[${C_PRE}m%s${C_RESET}\n" "$1" } @@ -590,10 +596,15 @@ extract_links() { gawk ' /^=>/ { sub(/=>[[:space:]]*/,"") - if ($2) - printf "%s (\033[34m%s\033[0m)\n", $1, $2 - else + if ($2) { + rest="" + for (i=2;i<=NF;i++) { + rest=rest (rest?" ":"")$i + } + printf "%s (\033[34m%s\033[0m)\n", $1, rest + } else { printf "%s\n", $1 + } }' } -- cgit 1.4.1-21-gabe81