Skip to content

Commit da040f6

Browse files
A Dynamic Collection of Shell Scripts with Educational Purpose
1 parent fe6d9c7 commit da040f6

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

scripts/ble-simple

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -519,14 +519,23 @@ _gt_overlay() {
519519
ghost="${_gt_gh}${_GT_SUGGESTION:${#line}}${_gt_b0}"
520520
fi
521521

522-
printf 'OVERLAY line="%s" ghost="%s" col=%s\n' \
523-
"$line" "${ghost:0:20}" "$(( _CS_PS1_LEN + ${#line} + 1 ))" >> "${TMPDIR}/cs_debug.log"
524-
522+
local _term_cols; _term_cols=$(tput cols 2>/dev/null || printf '80')
525523
local col=$(( _CS_PS1_LEN + ${#line} + 1 ))
526-
if [[ -z "$ghost" ]]; then
527-
printf '\e[s\e[%dG\e[K\e[u' "$col" >&2
524+
local cursor_col=$(( ( _CS_PS1_LEN + _CS_POS ) % _term_cols + 1 ))
525+
526+
if [[ -n "$TERMUX_VERSION" ]]; then
527+
# No Termux \e[s/\e[u causam loop — desenha ghost e reposiciona cursor explicitamente
528+
if [[ -z "$ghost" ]]; then
529+
printf '\e[%dG\e[K\e[%dG' "$col" "$cursor_col" >&2
530+
else
531+
printf '\e[%dG\e[K%s\e[%dG' "$col" "$ghost" "$cursor_col" >&2
532+
fi
528533
else
529-
printf '\e[s\e[%dG\e[K%s\e[u' "$col" "$ghost" >&2
534+
if [[ -z "$ghost" ]]; then
535+
printf '\e[s\e[%dG\e[K\e[u' "$col" >&2
536+
else
537+
printf '\e[s\e[%dG\e[K%s\e[u' "$col" "$ghost" >&2
538+
fi
530539
fi
531540
}
532541

0 commit comments

Comments
 (0)