Shorten lines

Wanted to make sure all lines are less than 80 characters.
This commit is contained in:
Case Duckworth 2021-02-26 17:41:22 -06:00
parent 83af2d5cd7
commit b68064c326
1 changed files with 27 additions and 11 deletions

38
bollux
View File

@ -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]}"