[Feature] Add wish_remaining_chars.

wish_remaining_chars is to be used only in main functions of bodies
This commit is contained in:
Ceda EI 2019-12-24 22:46:52 +05:30
parent 97fe2dbcc6
commit 136567e08e
1 changed files with 13 additions and 0 deletions

13
wish.sh
View File

@ -100,6 +100,7 @@ function wish_append_right() {
fi fi
} }
# Public API
# Usage: wish_append bg fg text # Usage: wish_append bg fg text
# #
# Parameters: # Parameters:
@ -136,6 +137,18 @@ function wish_append() {
fi 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() { function wish_main() {
local prev=$? local prev=$?