Repo Browser

bashcards/bashcards-edu-biology
cards/914427098424--what-is-biology/assets/raw.sh
#!/usr/bin/env bash
set +e
tt="/dev/tty";[[ -r "$tt" && -w "$tt" ]]||tt=""
p(){ [[ -n "$tt" ]]&&printf "%b" "$1" >"$tt"||printf "%b" "$1"; }
r(){ local t=""; if [[ -n "$tt" ]]; then IFS= read -r t <"$tt" || t=""; else IFS= read -r t || t=""; fi; printf "%s" "$t"; }

W=60
deck="EDU";subject="EDU";
topic="Introduction to Biology";
subtitle="Basics of Living Organisms and Their Interactions";
note="Biology helps us understand all forms of life and their roles in nature. Whether you are a child or an adult, learning biology shows how living things grow, change, and depend on each other.";
cl(){ printf "\033[2J\033[H"; }
bar(){ printf "%s\n" "$(printf "%*s" "$W" "" | tr " " "=")"; }
row(){ printf "| %-*.*s |\n" "$((W-4))" "$((W-4))" "$1"; }
wrap(){
  local txt="$1" max=$((W-4)) chunk rest cut
  while [[ -n "$txt" ]]; do
    if [[ ${#txt} -le $max ]]; then row "$txt"; break; fi
    chunk=${txt:0:$max}
    rest=${txt:$max}
    if [[ "$chunk" =~ (.+)[[:space:]] ]]; then
      cut=${BASH_REMATCH[1]}
      row "$cut"
      txt="${txt:${#cut}}"; txt="${txt#" "}";
    else
      row "$chunk"
      txt="$rest"
    fi
  done
}
pause(){ p "Press Enter to continue: "; r >/dev/null; }

menu(){
  cl
  bar; row "$deck • $subject"; bar
  wrap "$topic"
  wrap "$subtitle"
  if [[ -n "$note" ]]; then wrap "Tip: $note"; fi
  bar
  row "1) OVERVIEW"
  row "2) STEPS"
  row "3) TERMINOLOGY"
  row "q) EXIT"
  bar
  p "> "
}

page_OVERVIEW(){
  cl
  bar; row "OVERVIEW"; bar
  local s
  p=(
"Biology studies all living things and how they interact."
"It looks at life from tiny microbes to big animals and plants."
"We learn about how organisms grow, function, and evolve."
"Biology explains genetics, ecology, and how bodies work."
"It helps us understand life and protect our environment."
"Biology supports medicine, farming, and conservation efforts."
)
  for s in "${p[@]}"; do wrap "$s"; done
  bar
  pause
}

page_STEPS(){
  cl
  bar; row "STEPS"; bar
  local s
  p=(
"Define what biology is and why it matters."
"Explore different types of living organisms."
"Discuss how organisms interact with each other and their environment."
"Introduce basic biological processes like growth and reproduction."
"Explain the importance of genetics and evolution."
"Connect biology to real-world applications like health and environment."
)
  for s in "${p[@]}"; do wrap "$s"; done
  bar
  pause
}

page_TERMINOLOGY(){
  cl
  bar; row "TERMINOLOGY"; bar
  local s
  p=(
"Organism — any living thing, from tiny bacteria to large animals."
"Genetics — study of how traits are passed from parents to offspring."
"Ecology — study of how organisms interact with each other and their surroundings."
"Physiology — study of how living things function internally."
"Evolution — process by which species change over time."
"Microorganism — tiny living things, often too small to see without a microscope."
"Environment — the natural world where organisms live."
"Conservation — protecting and preserving natural resources and life forms."
)
  for s in "${p[@]}"; do wrap "$s"; done
  bar
  pause
}

while true; do
  menu
  read -r choice < "${tt:-/dev/stdin}" || choice=""
  case "$choice" in
    1) page_OVERVIEW ;;
    2) page_STEPS ;;
    3) page_TERMINOLOGY ;;
    q|Q) cl; bar; row "CARD CLOSED"; bar; p "\n"; break ;;
    *) cl; bar; row "Select 1-3 or q"; bar; pause ;;
  esac
done
NameTypeSize
auto-art.pngfile1,890,082
back-data-url.txtfile261,762
back-thumb.pngfile191,507
back.pngfile196,303
front-data-url.txtfile223,870
front-thumb.pngfile111,841
front.pngfile167,886
manifest.txtfile206
print-card.pdffile213,857
qr-payload.txtfile3,519
raw.shfile3,387