#!/usr/bin/env bash # ui/activity.module.sh — rendering for wgctl activity # ui::activity::peer_row function ui::activity::peer_row() { local name_pad="${1:-}" rx_pad="${2:-}" tx_pad="${3:-}" \ drops="${4:-0}" drop_word="${5:-drops}" w_drops="${6:-1}" printf " \033[1m%s\033[0m \033[2m↓\033[0m%s \033[2m↑\033[0m%s %${w_drops}s %s\n" \ "$name_pad" "$rx_pad" "$tx_pad" "$drops" "$drop_word" } # ui::activity::service_row function ui::activity::service_row() { local dest_display="${1:-}" drop_count="${2:-0}" drop_word="${3:-drops}" \ drops_col="${4:-30}" w_drops="${5:-1}" # Align drop count with peer drop column # Service row visible prefix: " → " (6 visible) + ${#dest_display} # But "→" is 3 bytes, 1 visible — arrow_prefix bytes = 8, visible = 6 local arrow_prefix=" → " local prefix_bytes=${#arrow_prefix} # 8 bytes due to → being 3 bytes local prefix_len=$(( prefix_bytes + ${#dest_display} )) local pad_n=$(( drops_col - prefix_len )) [[ $pad_n -lt 1 ]] && pad_n=1 printf " \033[2m→\033[0m %s%*s %${w_drops}s %s\n" \ "$dest_display" "$pad_n" "" "$drop_count" "$drop_word" } # Table versions (kept for future display config) function ui::activity::header_table() { printf "\n %-24s %-14s %-14s %s\n" "PEER" "↓ RX" "↑ TX" "DROPS" printf " %s\n" "$(printf '─%.0s' {1..65})" } function ui::activity::peer_row_table() { local name="${1:-}" rx_fmt="${2:-}" tx_fmt="${3:-}" \ drops="${4:-0}" drop_word="${5:-drops}" printf " %-24s %-14s %-14s %s %s\n" \ "$name" "↓$rx_fmt" "↑$tx_fmt" "$drops" "$drop_word" } function ui::activity::service_row_table() { local dest_display="${1:-}" drop_count="${2:-0}" drop_word="${3:-drops}" printf " → %-30s %s %s\n" "$dest_display" "$drop_count" "$drop_word" }