about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2020-05-30 16:45:56 -0500
committerCase Duckworth2020-05-30 16:45:56 -0500
commitcf5bbfa32b3d396b471542d97d4920c083c6a538 (patch)
tree13d1feeef648d5f5aa3891a4c7f0b4f3f0252a13
parentUpdate typesetting of text/gemini (diff)
downloadbollux-cf5bbfa32b3d396b471542d97d4920c083c6a538.tar.gz
bollux-cf5bbfa32b3d396b471542d97d4920c083c6a538.zip
Change margin stuff
-rwxr-xr-xbollux35
1 files 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() {
432 log d "LINES=$LINES; COLUMNS=$COLUMNS" 432 log d "LINES=$LINES; COLUMNS=$COLUMNS"
433 T_WIDTH=$COLUMNS 433 T_WIDTH=$COLUMNS
434 fi 434 fi
435 435 WIDTH=$((T_WIDTH - T_MARGIN))
436 WIDTH=$((T_WIDTH - (T_MARGIN * 2))) 436 ((WIDTH < 0)) && WIDTH=80 # default if dumb
437 ((WIDTH < 0)) && WIDTH=80 # default if dumb 437 S_MARGIN=$((T_MARGIN - 1)) # spacing
438 438
439 log d "T_WIDTH=$T_WIDTH" 439 log d "T_WIDTH=$T_WIDTH"
440 log d "WIDTH=$WIDTH" 440 log d "WIDTH=$WIDTH"
@@ -454,7 +454,13 @@ typeset_gemini() {
454 gemini_link "$REPLY" $pre "$ln" 454 gemini_link "$REPLY" $pre "$ln"
455 ;; 455 ;;
456 \#*) gemini_header "$REPLY" $pre ;; 456 \#*) gemini_header "$REPLY" $pre ;;
457 \**) gemini_list "$REPLY" $pre ;; 457 \**)
458 if [[ "$REPLY" =~ ^\*[[:space:]]+ ]]; then
459 gemini_list "$REPLY" $pre
460 else
461 gemini_text "$REPLY" $pre
462 fi
463 ;;
458 *) gemini_text "$REPLY" $pre ;; 464 *) gemini_text "$REPLY" $pre ;;
459 esac 465 esac
460 done 466 done
@@ -472,7 +478,7 @@ gemini_link() {
472 a= 478 a=
473 fi 479 fi
474 480
475 printf "\e[${C_SIGIL}m%-${T_MARGIN}s${C_RESET}" "$s" 481 printf "\e[${C_SIGIL}m%${S_MARGIN}s ${C_RESET}" "$s"
476 printf -v l "\e[${C_LINK_NUMBER}m[%d]${C_RESET} \ 482 printf -v l "\e[${C_LINK_NUMBER}m[%d]${C_RESET} \
477 \e[${C_LINK_TITLE}m%s${C_RESET} \ 483 \e[${C_LINK_TITLE}m%s${C_RESET} \
478 \e[${C_LINK_URL}m%s${C_RESET}\n" \ 484 \e[${C_LINK_URL}m%s${C_RESET}\n" \
@@ -493,7 +499,7 @@ gemini_header() {
493 local hdrfmt 499 local hdrfmt
494 hdrfmt="$(eval echo "\$C_HEADER$a")" 500 hdrfmt="$(eval echo "\$C_HEADER$a")"
495 501
496 printf "\e[${C_SIGIL}m%$((T_MARGIN - 1))s ${C_RESET}" "$s" 502 printf "\e[${C_SIGIL}m%${S_MARGIN}s ${C_RESET}" "$s"
497 printf -v l "\e[${hdrfmt}m%s${C_RESET}\n" "$t" 503 printf -v l "\e[${hdrfmt}m%s${C_RESET}\n" "$t"
498 fold_line "$WIDTH" "$l" 504 fold_line "$WIDTH" "$l"
499 else 505 else
@@ -508,7 +514,7 @@ gemini_list() {
508 s="${BASH_REMATCH[1]}" 514 s="${BASH_REMATCH[1]}"
509 t="${BASH_REMATCH[2]}" 515 t="${BASH_REMATCH[2]}"
510 516
511 printf "\e[${C_SIGIL}m%-${T_MARGIN}s" "$s" 517 printf "\e[${C_SIGIL}m%${S_MARGIN}s " "$s"
512 printf -v l "\e[${C_LIST}m%s${C_RESET}\n" "$t" 518 printf -v l "\e[${C_LIST}m%s${C_RESET}\n" "$t"
513 fold_line "$WIDTH" "$l" 519 fold_line "$WIDTH" "$l"
514 else 520 else
@@ -518,7 +524,7 @@ gemini_list() {
518 524
519gemini_text() { 525gemini_text() {
520 if ! ${2-false}; then 526 if ! ${2-false}; then
521 printf "%${T_MARGIN}s" ' ' 527 printf "%${S_MARGIN}s " ' '
522 fold_line "$WIDTH" "$1" 528 fold_line "$WIDTH" "$1"
523 else 529 else
524 gemini_pre "$1" 530 gemini_pre "$1"
@@ -526,7 +532,7 @@ gemini_text() {
526} 532}
527 533
528gemini_pre() { 534gemini_pre() {
529 printf "\e[${C_SIGIL}m%-${T_MARGIN}s" '```' 535 printf "\e[${C_SIGIL}m%${S_MARGIN}s " '```'
530 printf "\e[${C_PRE}m%s${C_RESET}\n" "$1" 536 printf "\e[${C_PRE}m%s${C_RESET}\n" "$1"
531} 537}
532 538
@@ -590,10 +596,15 @@ extract_links() {
590 gawk ' 596 gawk '
591 /^=>/ { 597 /^=>/ {
592 sub(/=>[[:space:]]*/,"") 598 sub(/=>[[:space:]]*/,"")
593 if ($2) 599 if ($2) {
594 printf "%s (\033[34m%s\033[0m)\n", $1, $2 600 rest=""
595 else 601 for (i=2;i<=NF;i++) {
602 rest=rest (rest?" ":"")$i
603 }
604 printf "%s (\033[34m%s\033[0m)\n", $1, rest
605 } else {
596 printf "%s\n", $1 606 printf "%s\n", $1
607 }
597 }' 608 }'
598} 609}
599 610