From 136567e08ec0228ffedcce77bb2aded7bb53211b Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Tue, 24 Dec 2019 22:46:52 +0530 Subject: [PATCH] [Feature] Add wish_remaining_chars. wish_remaining_chars is to be used only in main functions of bodies --- wish.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/wish.sh b/wish.sh index de68731..c0b6f93 100644 --- a/wish.sh +++ b/wish.sh @@ -100,6 +100,7 @@ function wish_append_right() { fi } +# Public API # Usage: wish_append bg fg text # # Parameters: @@ -136,6 +137,18 @@ function wish_append() { fi } +# Public API +# Usage: wish_remaining_chars +# Parameters: None +# Return Value: Capture stdout to get the remaining characters available in the +# line. +wish_remaining_chars() { + if [[ $WISH_STATE -eq 0 ]]; then + echo "$(( $COLUMNS - ${WISH_LPL[$WISH_LPLINE]} ))" + else + echo "$(( $COLUMNS - ${WISH_LPL[$WISH_RPLINE]} - ${WISH_RPL[$WISH_RPLINE]} ))" + fi +} function wish_main() { local prev=$?