From b68064c3262d86abdbe9ed2b29c062f5af357967 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 26 Feb 2021 17:41:22 -0600 Subject: Shorten lines Wanted to make sure all lines are less than 80 characters. --- bollux | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/bollux b/bollux index d58aac3..5ccd2ba 100755 --- a/bollux +++ b/bollux @@ -126,8 +126,8 @@ bollux_config() { : "${BOLLUX_DATADIR:=${XDG_DATA_DIR:-$HOME/.local/share}/bollux}" : "${BOLLUX_DOWNDIR:=.}" # where to save downloads : "${BOLLUX_LESSKEY:=$BOLLUX_DATADIR/lesskey}" # where to store binds - : "${BOLLUX_PAGESRC:=$BOLLUX_DATADIR/pagesrc}" # where to save the source - BOLLUX_HISTFILE="$BOLLUX_DATADIR/history" # where to save the history + : "${BOLLUX_PAGESRC:=$BOLLUX_DATADIR/pagesrc}" # where to save source + BOLLUX_HISTFILE="$BOLLUX_DATADIR/history" # where to save history ## typesetting : "${T_MARGIN:=4}" # left and right margin : "${T_WIDTH:=0}" # width of the viewport -- 0 = get term width @@ -199,7 +199,9 @@ blastoff() { # blastoff [-u] URL if declare -Fp "${url[1]}_response" >/dev/null 2>&1; then run "${url[1]}_response" "$url" else - log d "No response handler for '${url[1]}', passing thru" + log d \ + "No response handler for '${url[1]}';" \ + " passing thru" passthru fi } @@ -674,10 +676,14 @@ display() { # display METADATA [TITLE] mklesskey "$BOLLUX_LESSKEY" && less_cmd+=(-k "$BOLLUX_LESSKEY") local helpline="o:open, g/G:goto, [:back, ]:forward, r:refresh" less_cmd+=( - -Pm"$(less_prompt_escape "$BOLLUX_URL") - bollux$" # 'status'line - -P="$(less_prompt_escape "$helpline")$" # helpline - -m # start with statusline - +k # float content to the top + # 'status'line + -Pm"$(less_prompt_escape "$BOLLUX_URL") - bollux$" + # helpline + -P="$(less_prompt_escape "$helpline")$" + # start with statusline + -m + # float content to the top + +k ) local typeset @@ -806,8 +812,10 @@ gemini_link() { fold_line -n -B "\e[${C_LINK_TITLE}m" -A "${C_RESET}" \ -l "$((${#ln} + 3))" -m "${T_MARGIN}" \ "$WIDTH" "$(trim_string "$t")" - fold_line -B " \e[${C_LINK_URL}m" -A "${C_RESET}" \ - -l "$((${#ln} + 3 + ${#t}))" -m "$((T_MARGIN + ${#ln} + 2))" \ + fold_line -B " \e[${C_LINK_URL}m" \ + -A "${C_RESET}" \ + -l "$((${#ln} + 3 + ${#t}))" \ + -m "$((T_MARGIN + ${#ln} + 2))" \ "$WIDTH" "$a" else gemini_pre "$1" @@ -879,7 +887,13 @@ gemini_pre() { # wrap lines on words to WIDTH fold_line() { - # fold_line [-n] [-m MARGIN] [-f MARGIN] [-l LENGTH] [-B BEFORE] [-A AFTER] WIDTH TEXT + # fold_line [-n] + # [-m MARGIN] + # [-f MARGIN] + # [-l LENGTH] + # [-B BEFORE] + # [-A AFTER] + # WIDTH TEXT local newline=true local -i margin_all=0 margin_first=0 width ll=0 wl=0 wn=0 local before="" after="" @@ -995,8 +1009,10 @@ select_url() { # select_url FILE # extract the links from a text/gemini file extract_links() { local url alt + local re="^=>[[:space:]]*([^[:space:]]+)([[:space:]]+(.*))?$" while read -r; do - if [[ "$REPLY" =~ ^=\>[[:space:]]*([^[:space:]]+)([[:space:]]+(.*))?$ ]]; then + log d $re + if [[ $REPLY =~ $re ]]; then url="${BASH_REMATCH[1]}" alt="${BASH_REMATCH[3]}" -- cgit 1.4.1-21-gabe81