aboutsummaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2011-06-20 19:34:07 +0200
committerTom Gundersen <teg@jklm.no>2011-06-20 19:34:07 +0200
commit3498c2a1b387fb83a960e6ed1faaa3e5fd68fa50 (patch)
tree521ac44f8000b1a4df9b526b5c85ce841d3302a3 /functions
parent60191a3cdf4923fea04ae1fb383b9367db9227a0 (diff)
downloadinitscripts-3498c2a1b387fb83a960e6ed1faaa3e5fd68fa50.tar.xz
status: adjust number of columns after loading modules
In case loading modules enables a frambuffer with higher resolution than the standard 80 columns, we recalculate the number of columns after all modules have been loaded. Original-patch-by: Aaron Griffin <aaronmgriffin@gmail.com> Original-patch-by: Søren Poulsen <nikorpoulsen@gmail.com> Signed-off-by: Tom Gundersen <teg@jklm.no>
Diffstat (limited to 'functions')
-rw-r--r--functions60
1 files changed, 32 insertions, 28 deletions
diff --git a/functions b/functions
index d94a9ef..d0747ba 100644
--- a/functions
+++ b/functions
@@ -4,26 +4,40 @@
# width:
-STAT_COL=80
-if [[ ! -t 1 ]]; then
- USECOLOR=""
-elif [[ -t 0 ]]; then
- # stty will fail when stdin isn't a terminal
- STAT_COL="$(/bin/stty size)"
- # stty gives "rows cols"; strip the rows number, we just want columns
- STAT_COL="${STAT_COL##* }"
-elif /bin/tput cols &>/dev/null; then
- # is /usr/share/terminfo already mounted, and TERM recognized?
- STAT_COL=$(/bin/tput cols)
-fi
-if ((STAT_COL==0)); then
- # if output was 0 (serial console), set default width to 80
+calc_columns () {
STAT_COL=80
- USECOLOR=""
-fi
+ if [[ ! -t 1 ]]; then
+ USECOLOR=""
+ elif [[ -t 0 ]]; then
+ # stty will fail when stdin isn't a terminal
+ STAT_COL="$(/bin/stty size)"
+ # stty gives "rows cols"; strip the rows number, we just want columns
+ STAT_COL="${STAT_COL##* }"
+ elif /bin/tput cols &>/dev/null; then
+ # is /usr/share/terminfo already mounted, and TERM recognized?
+ STAT_COL=$(/bin/tput cols)
+ fi
+ if ((STAT_COL==0)); then
+ # if output was 0 (serial console), set default width to 80
+ STAT_COL=80
+ USECOLOR=""
+ fi
+
+ # we use 13 characters for our own stuff
+ STAT_COL=$(($STAT_COL - 13))
+
+ if [[ -t 1 ]]; then
+ SAVE_POSITION="\e[s"
+ RESTORE_POSITION="\e[u"
+ DEL_TEXT="\e[$(($STAT_COL+4))G"
+ else
+ SAVE_POSITION=""
+ RESTORE_POSITION=""
+ DEL_TEXT=""
+ fi
+}
-# we use 13 characters for our own stuff
-STAT_COL=$(($STAT_COL - 13))
+calc_columns
# disable colors on broken terminals
TERM_COLORS="$(/bin/tput colors 2>/dev/null)"
@@ -76,16 +90,6 @@ if [[ $USECOLOR =~ yes|YES ]]; then
fi
fi
-if [[ -t 1 ]]; then
- SAVE_POSITION="\e[s"
- RESTORE_POSITION="\e[u"
- DEL_TEXT="\e[$(($STAT_COL+4))G"
-else
- SAVE_POSITION=""
- RESTORE_POSITION=""
- DEL_TEXT=""
-fi
-
# prefixes:
PREFIX_REG="::"