Skip to content

Commit

Permalink
Hide cursor if ansi escapes are supported
Browse files Browse the repository at this point in the history
  • Loading branch information
Akianonymus committed Oct 27, 2020
1 parent 6653552 commit d3f0e8b
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 12 deletions.
3 changes: 1 addition & 2 deletions bash/common-utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ _check_debug() {
else
trap 'shopt -s checkwinsize; (:;:)' SIGWINCH
fi
CURL_PROGRESS="-#" EXTRA_LOG="_print_center" CURL_PROGRESS_EXTRA="-#"
export CURL_PROGRESS EXTRA_LOG CURL_PROGRESS_EXTRA
export CURL_PROGRESS="-#" EXTRA_LOG="_print_center" CURL_PROGRESS_EXTRA="-#" SUPPORT_ANSI_ESCAPES="true"
else
_print_center() { { [[ $# = 3 ]] && printf "%s\n" "[ ${2} ]"; } || { printf "%s\n" "[ ${2}${3} ]"; }; }
_clear_line() { :; }
Expand Down
3 changes: 1 addition & 2 deletions bash/release/gsync
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ _check_debug() {
else
trap 'shopt -s checkwinsize; (:;:)' SIGWINCH
fi
CURL_PROGRESS="-#" EXTRA_LOG="_print_center" CURL_PROGRESS_EXTRA="-#"
export CURL_PROGRESS EXTRA_LOG CURL_PROGRESS_EXTRA
export CURL_PROGRESS="-#" EXTRA_LOG="_print_center" CURL_PROGRESS_EXTRA="-#" SUPPORT_ANSI_ESCAPES="true"
else
_print_center() { { [[ $# = 3 ]] && printf "%s\n" "[ ${2} ]"; } || { printf "%s\n" "[ ${2}${3} ]"; }; }
_clear_line() { :; }
Expand Down
9 changes: 7 additions & 2 deletions bash/release/gupload
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ _check_debug() {
else
trap 'shopt -s checkwinsize; (:;:)' SIGWINCH
fi
CURL_PROGRESS="-#" EXTRA_LOG="_print_center" CURL_PROGRESS_EXTRA="-#"
export CURL_PROGRESS EXTRA_LOG CURL_PROGRESS_EXTRA
export CURL_PROGRESS="-#" EXTRA_LOG="_print_center" CURL_PROGRESS_EXTRA="-#" SUPPORT_ANSI_ESCAPES="true"
else
_print_center() { { [[ $# = 3 ]] && printf "%s\n" "[ ${2} ]"; } || { printf "%s\n" "[ ${2}${3} ]"; }; }
_clear_line() { :; }
Expand Down Expand Up @@ -1562,6 +1561,9 @@ main() {

_cleanup() {
{
# unhide the cursor if hidden
[[ -n ${SUPPORT_ANSI_ESCAPES} ]] && printf "\033[?25h"

[[ -n ${PARALLEL_UPLOAD} ]] && rm -f "${TMPFILE:?}"*

# manually kill all script children pids
Expand Down Expand Up @@ -1602,6 +1604,9 @@ main() {
_print_center "justify" "Workspace Folder: ${WORKSPACE_FOLDER_NAME}" "="
_print_center "normal" " ${WORKSPACE_FOLDER_ID} " "-" && _newline "\n"

# hide the cursor if ansi escapes are supported
[[ -n ${SUPPORT_ANSI_ESCAPES} ]] && printf "\033[?25l"

_process_arguments

END="$(printf "%(%s)T\\n" "-1")"
Expand Down
6 changes: 6 additions & 0 deletions bash/upload.bash
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,9 @@ main() {

_cleanup() {
{
# unhide the cursor if hidden
[[ -n ${SUPPORT_ANSI_ESCAPES} ]] && printf "\033[?25h"

[[ -n ${PARALLEL_UPLOAD} ]] && rm -f "${TMPFILE:?}"*

# manually kill all script children pids
Expand Down Expand Up @@ -677,6 +680,9 @@ main() {
_print_center "justify" "Workspace Folder: ${WORKSPACE_FOLDER_NAME}" "="
_print_center "normal" " ${WORKSPACE_FOLDER_ID} " "-" && _newline "\n"

# hide the cursor if ansi escapes are supported
[[ -n ${SUPPORT_ANSI_ESCAPES} ]] && printf "\033[?25l"

_process_arguments

END="$(printf "%(%s)T\\n" "-1")"
Expand Down
3 changes: 1 addition & 2 deletions sh/common-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ _check_debug() {
if _support_ansi_escapes; then
! COLUMNS="$(_get_columns_size)" || [ "${COLUMNS:-0}" -lt 45 ] 2>| /dev/null &&
_print_center() { { [ $# = 3 ] && printf "%s\n" "[ ${2} ]"; } || { printf "%s\n" "[ ${2}${3} ]"; }; }
CURL_PROGRESS="-#" EXTRA_LOG="_print_center" CURL_PROGRESS_EXTRA="-#"
export CURL_PROGRESS EXTRA_LOG CURL_PROGRESS_EXTRA
export CURL_PROGRESS="-#" EXTRA_LOG="_print_center" CURL_PROGRESS_EXTRA="-#" SUPPORT_ANSI_ESCAPES="true"
else
_print_center() { { [ $# = 3 ] && printf "%s\n" "[ ${2} ]"; } || { printf "%s\n" "[ ${2}${3} ]"; }; }
_clear_line() { :; }
Expand Down
3 changes: 1 addition & 2 deletions sh/release/gsync
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ _check_debug() {
if _support_ansi_escapes; then
! COLUMNS="$(_get_columns_size)" || [ "${COLUMNS:-0}" -lt 45 ] 2>| /dev/null &&
_print_center() { { [ $# = 3 ] && printf "%s\n" "[ ${2} ]"; } || { printf "%s\n" "[ ${2}${3} ]"; }; }
CURL_PROGRESS="-#" EXTRA_LOG="_print_center" CURL_PROGRESS_EXTRA="-#"
export CURL_PROGRESS EXTRA_LOG CURL_PROGRESS_EXTRA
export CURL_PROGRESS="-#" EXTRA_LOG="_print_center" CURL_PROGRESS_EXTRA="-#" SUPPORT_ANSI_ESCAPES="true"
else
_print_center() { { [ $# = 3 ] && printf "%s\n" "[ ${2} ]"; } || { printf "%s\n" "[ ${2}${3} ]"; }; }
_clear_line() { :; }
Expand Down
9 changes: 7 additions & 2 deletions sh/release/gupload
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ _check_debug() {
if _support_ansi_escapes; then
! COLUMNS="$(_get_columns_size)" || [ "${COLUMNS:-0}" -lt 45 ] 2>| /dev/null &&
_print_center() { { [ $# = 3 ] && printf "%s\n" "[ ${2} ]"; } || { printf "%s\n" "[ ${2}${3} ]"; }; }
CURL_PROGRESS="-#" EXTRA_LOG="_print_center" CURL_PROGRESS_EXTRA="-#"
export CURL_PROGRESS EXTRA_LOG CURL_PROGRESS_EXTRA
export CURL_PROGRESS="-#" EXTRA_LOG="_print_center" CURL_PROGRESS_EXTRA="-#" SUPPORT_ANSI_ESCAPES="true"
else
_print_center() { { [ $# = 3 ] && printf "%s\n" "[ ${2} ]"; } || { printf "%s\n" "[ ${2}${3} ]"; }; }
_clear_line() { :; }
Expand Down Expand Up @@ -1571,6 +1570,9 @@ main() {
_cleanup() {
{
# unhide the cursor if hidden
[ -n "${SUPPORT_ANSI_ESCAPES}" ] && printf "\033[?25h"
[ -n "${PARALLEL_UPLOAD}" ] && rm -f "${TMPFILE:?}"*
# manually kill all script children pids
Expand Down Expand Up @@ -1611,6 +1613,9 @@ main() {
_print_center "justify" "Workspace Folder: ${WORKSPACE_FOLDER_NAME}" "="
"${HIDE_INFO:-_print_center}" "normal" " ${WORKSPACE_FOLDER_ID} " "-" && _newline "\n"
# hide the cursor if ansi escapes are supported
[ -n "${SUPPORT_ANSI_ESCAPES}" ] && printf "\033[?25l"
_process_arguments
END="$(date +'%s')"
Expand Down
6 changes: 6 additions & 0 deletions sh/upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,9 @@ main() {
_cleanup() {
{
# unhide the cursor if hidden
[ -n "${SUPPORT_ANSI_ESCAPES}" ] && printf "\033[?25h"
[ -n "${PARALLEL_UPLOAD}" ] && rm -f "${TMPFILE:?}"*
# manually kill all script children pids
Expand Down Expand Up @@ -703,6 +706,9 @@ main() {
_print_center "justify" "Workspace Folder: ${WORKSPACE_FOLDER_NAME}" "="
"${HIDE_INFO:-_print_center}" "normal" " ${WORKSPACE_FOLDER_ID} " "-" && _newline "\n"
# hide the cursor if ansi escapes are supported
[ -n "${SUPPORT_ANSI_ESCAPES}" ] && printf "\033[?25l"
_process_arguments
END="$(date +'%s')"
Expand Down

0 comments on commit d3f0e8b

Please sign in to comment.