feat: Improve performance for empty line print for larger lists
This commit is contained in:
+10
-3
@@ -25,7 +25,14 @@ _key_input() {
|
|||||||
|
|
||||||
# print new line for empty element in array
|
# print new line for empty element in array
|
||||||
# shellcheck disable=SC2231
|
# shellcheck disable=SC2231
|
||||||
_new_line_foreach_item() { for _ in $1[@]; do echo -en "\n" >&2; done }
|
_new_line_foreach_item() {
|
||||||
|
count=0
|
||||||
|
while [[ $count -lt $1 ]];
|
||||||
|
do
|
||||||
|
echo "" >&2
|
||||||
|
((count++))
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# display prompt text without linebreak
|
# display prompt text without linebreak
|
||||||
_prompt_text() {
|
_prompt_text() {
|
||||||
@@ -122,7 +129,7 @@ list() {
|
|||||||
|
|
||||||
local opts=("${@:2}")
|
local opts=("${@:2}")
|
||||||
local opts_count=$(($# -1))
|
local opts_count=$(($# -1))
|
||||||
_new_line_foreach_item "${opts[*]}"
|
_new_line_foreach_item "${#opts[@]}"
|
||||||
|
|
||||||
# determine current screen position for overwriting the options
|
# determine current screen position for overwriting the options
|
||||||
local lastrow; lastrow=$(_get_cursor_row)
|
local lastrow; lastrow=$(_get_cursor_row)
|
||||||
@@ -179,7 +186,7 @@ checkbox() {
|
|||||||
|
|
||||||
local opts; opts=("${@:2}")
|
local opts; opts=("${@:2}")
|
||||||
local opts_count; opts_count=$(($# -1))
|
local opts_count; opts_count=$(($# -1))
|
||||||
_new_line_foreach_item "${opts[*]}"
|
_new_line_foreach_item "${#opts[@]}"
|
||||||
|
|
||||||
# determine current screen position for overwriting the options
|
# determine current screen position for overwriting the options
|
||||||
local lastrow; lastrow=$(_get_cursor_row)
|
local lastrow; lastrow=$(_get_cursor_row)
|
||||||
|
|||||||
Reference in New Issue
Block a user