Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions hdi
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ declare -a CMD_INDICES=() # indices into DISPLAY_LINES that are commands
declare -a SECTION_FIRST_CMD=() # cursor indices (into CMD_INDICES) of first cmd per section

build_display_list() {
_MAX_CONTENT_WIDTH=0
for i in "${!SECTION_TITLES[@]}"; do
local title="${SECTION_TITLES[$i]}"
local body="${SECTION_BODIES[$i]}"
Expand Down Expand Up @@ -559,6 +560,7 @@ build_display_list() {
DISPLAY_LINES+=("$tcmd")
LINE_TYPES+=("command")
LINE_CMDS+=("$tcmd")
(( ${#tcmd} + 4 > _MAX_CONTENT_WIDTH )) && _MAX_CONTENT_WIDTH=$(( ${#tcmd} + 4 ))
done <<< "$title_cmds"
fi

Expand Down Expand Up @@ -620,6 +622,7 @@ build_display_list() {
DISPLAY_LINES+=("$_entry")
LINE_TYPES+=("command")
LINE_CMDS+=("$_entry")
(( ${#_entry} + 4 > _MAX_CONTENT_WIDTH )) && _MAX_CONTENT_WIDTH=$(( ${#_entry} + 4 ))
done <<< "$cmds"
fi

Expand Down Expand Up @@ -647,7 +650,7 @@ render_static() {
if $RAW; then
printf "\n## %s\n" "$line"
else
printf "\n%s%s ▸ %s%s\n" "$BOLD" "$CYAN" "$line" "$RESET"
_section_header "$line"; printf "\n%s\n" "$_SH"
fi
;;
subheader)
Expand Down Expand Up @@ -698,7 +701,7 @@ render_full() {
continue
fi

printf "\n%s%s ▸ %s%s\n" "$BOLD" "$CYAN" "$title" "$RESET"
_section_header "$title"; printf "\n%s\n" "$_SH"

local in_code=false
local code_buf=""
Expand Down Expand Up @@ -806,6 +809,21 @@ _term_height() {
echo 24
}

# Pre-computed dash string (200 chars covers any reasonable terminal width)
_DASH_POOL="────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────"

# Format a section header with trailing dashes (sets _SH, no subshell)
# _MAX_CONTENT_WIDTH is computed during build_display_list
_SH=""
_section_header() {
local prefix=" ▸ $1 "
local prefix_len=${#prefix}
local target=$(( _MAX_CONTENT_WIDTH > prefix_len ? _MAX_CONTENT_WIDTH : prefix_len + 4 ))
local n=$(( target - prefix_len ))
(( n < 2 )) && n=2
_SH="${BOLD}${CYAN}${prefix}${RESET}${DIM}${_DASH_POOL:0:n}${RESET}"
}

# Screen lines per display entry type — sets _SL (no subshell)
# Headers/subheaders take 2 lines (blank + text), others take 1
_SL=1
Expand Down Expand Up @@ -945,7 +963,8 @@ draw_picker() {
all) hdr+=" ${DIM}[all]${RESET}" ;;
esac
_line "$hdr"
local chrome=3
_blank
local chrome=4

# Scroll-up indicator (only if meaningful content is above the viewport)
local has_above=false
Expand Down Expand Up @@ -986,7 +1005,7 @@ draw_picker() {
if (( idx != VIEWPORT_TOP )); then
_blank; (( rendered += 1 ))
fi
_line "${BOLD}${CYAN} ▸ ${line}${RESET}"
_section_header "$line"; _line "$_SH"
(( rendered += 1 ))
;;
subheader)
Expand Down Expand Up @@ -1482,11 +1501,18 @@ _PLATFORM_DISPLAY=""
build_platform_display() {
_PLATFORM_DISPLAY=""
if (( ${#PLATFORM_NAMES[@]} == 0 )); then return; fi
local parts=""
local parts="" prev_low=false
for i in "${!PLATFORM_NAMES[@]}"; do
if [[ -n "$parts" ]]; then parts+=", "; fi
if [[ -n "$parts" ]]; then
if $prev_low; then parts+=" "; else parts+=", "; fi
fi
parts+="${PLATFORM_NAMES[$i]}"
if [[ "${PLATFORM_CONFIDENCE[$i]}" == "low" ]]; then parts+="?"; fi
if [[ "${PLATFORM_CONFIDENCE[$i]}" == "low" ]]; then
parts+="?"
prev_low=true
else
prev_low=false
fi
done
_PLATFORM_DISPLAY="$parts"
}
Expand Down Expand Up @@ -1817,7 +1843,7 @@ else
;;
all) printf " %s[all]%s" "$DIM" "$RESET" ;;
esac
printf "\n"
printf "\n\n"
fi

if $FULL; then
Expand Down
3 changes: 3 additions & 0 deletions src/display.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ declare -a CMD_INDICES=() # indices into DISPLAY_LINES that are commands
declare -a SECTION_FIRST_CMD=() # cursor indices (into CMD_INDICES) of first cmd per section

build_display_list() {
_MAX_CONTENT_WIDTH=0
for i in "${!SECTION_TITLES[@]}"; do
local title="${SECTION_TITLES[$i]}"
local body="${SECTION_BODIES[$i]}"
Expand Down Expand Up @@ -37,6 +38,7 @@ build_display_list() {
DISPLAY_LINES+=("$tcmd")
LINE_TYPES+=("command")
LINE_CMDS+=("$tcmd")
(( ${#tcmd} + 4 > _MAX_CONTENT_WIDTH )) && _MAX_CONTENT_WIDTH=$(( ${#tcmd} + 4 ))
done <<< "$title_cmds"
fi

Expand Down Expand Up @@ -98,6 +100,7 @@ build_display_list() {
DISPLAY_LINES+=("$_entry")
LINE_TYPES+=("command")
LINE_CMDS+=("$_entry")
(( ${#_entry} + 4 > _MAX_CONTENT_WIDTH )) && _MAX_CONTENT_WIDTH=$(( ${#_entry} + 4 ))
done <<< "$cmds"
fi

Expand Down
2 changes: 1 addition & 1 deletion src/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ else
;;
all) printf " %s[all]%s" "$DIM" "$RESET" ;;
esac
printf "\n"
printf "\n\n"
fi

if $FULL; then
Expand Down
20 changes: 18 additions & 2 deletions src/picker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ _term_height() {
echo 24
}

# Pre-computed dash string (200 chars covers any reasonable terminal width)
_DASH_POOL="────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────"

# Format a section header with trailing dashes (sets _SH, no subshell)
# _MAX_CONTENT_WIDTH is computed during build_display_list
_SH=""
_section_header() {
local prefix=" ▸ $1 "
local prefix_len=${#prefix}
local target=$(( _MAX_CONTENT_WIDTH > prefix_len ? _MAX_CONTENT_WIDTH : prefix_len + 4 ))
local n=$(( target - prefix_len ))
(( n < 2 )) && n=2
_SH="${BOLD}${CYAN}${prefix}${RESET}${DIM}${_DASH_POOL:0:n}${RESET}"
}

# Screen lines per display entry type — sets _SL (no subshell)
# Headers/subheaders take 2 lines (blank + text), others take 1
_SL=1
Expand Down Expand Up @@ -158,7 +173,8 @@ draw_picker() {
all) hdr+=" ${DIM}[all]${RESET}" ;;
esac
_line "$hdr"
local chrome=3
_blank
local chrome=4

# Scroll-up indicator (only if meaningful content is above the viewport)
local has_above=false
Expand Down Expand Up @@ -199,7 +215,7 @@ draw_picker() {
if (( idx != VIEWPORT_TOP )); then
_blank; (( rendered += 1 ))
fi
_line "${BOLD}${CYAN} ▸ ${line}${RESET}"
_section_header "$line"; _line "$_SH"
(( rendered += 1 ))
;;
subheader)
Expand Down
13 changes: 10 additions & 3 deletions src/platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,18 @@ _PLATFORM_DISPLAY=""
build_platform_display() {
_PLATFORM_DISPLAY=""
if (( ${#PLATFORM_NAMES[@]} == 0 )); then return; fi
local parts=""
local parts="" prev_low=false
for i in "${!PLATFORM_NAMES[@]}"; do
if [[ -n "$parts" ]]; then parts+=", "; fi
if [[ -n "$parts" ]]; then
if $prev_low; then parts+=" "; else parts+=", "; fi
fi
parts+="${PLATFORM_NAMES[$i]}"
if [[ "${PLATFORM_CONFIDENCE[$i]}" == "low" ]]; then parts+="?"; fi
if [[ "${PLATFORM_CONFIDENCE[$i]}" == "low" ]]; then
parts+="?"
prev_low=true
else
prev_low=false
fi
done
_PLATFORM_DISPLAY="$parts"
}
4 changes: 2 additions & 2 deletions src/render.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ render_static() {
if $RAW; then
printf "\n## %s\n" "$line"
else
printf "\n%s%s ▸ %s%s\n" "$BOLD" "$CYAN" "$line" "$RESET"
_section_header "$line"; printf "\n%s\n" "$_SH"
fi
;;
subheader)
Expand Down Expand Up @@ -60,7 +60,7 @@ render_full() {
continue
fi

printf "\n%s%s ▸ %s%s\n" "$BOLD" "$CYAN" "$title" "$RESET"
_section_header "$title"; printf "\n%s\n" "$_SH"

local in_code=false
local code_buf=""
Expand Down