X-Git-Url: http://git.ipfire.org/?p=people%2Fpmueller%2Fipfire-2.x.git;a=blobdiff_plain;f=make.sh;h=22724aa87235d924be3250a69736118e094b3903;hp=44516af73685f08d1c80b39c5510aa7449d11879;hb=401a1edc5688733821e69d885132025703944823;hpb=aceb943b237da1ade8efab458662f187925d160b diff --git a/make.sh b/make.sh index 44516af736..22724aa872 100755 --- a/make.sh +++ b/make.sh @@ -52,27 +52,33 @@ else INTERACTIVE=false fi -## Screen Dimentions -# Find current screen size -if [ -z "${COLUMNS}" ]; then - COLUMNS=$(stty size) - COLUMNS=${COLUMNS##* } -fi +# Sets or adjusts pretty formatting variables +resize_terminal() { + ## Screen Dimentions + # Find current screen size + COLUMNS=$(tput cols) + + # When using remote connections, such as a serial port, stty size returns 0 + if ! ${INTERACTIVE} || [ "${COLUMNS}" = "0" ]; then + COLUMNS=80 + fi -# When using remote connections, such as a serial port, stty size returns 0 -if ! ${INTERACTIVE} || [ "${COLUMNS}" = "0" ]; then - COLUMNS=80 -fi + # Measurements for positioning result messages + OPTIONS_WIDTH=20 + TIME_WIDTH=12 + STATUS_WIDTH=8 + NAME_WIDTH=$(( COLUMNS - OPTIONS_WIDTH - TIME_WIDTH - STATUS_WIDTH )) + LINE_WIDTH=$(( COLUMNS - STATUS_WIDTH )) + + TIME_COL=$(( COLUMNS - TIME_WIDTH - STATUS_WIDTH )) + STATUS_COL=$(( COLUMNS - STATUS_WIDTH )) +} -## Measurements for positioning result messages -OPTIONS_WIDTH=20 -TIME_WIDTH=12 -STATUS_WIDTH=8 -NAME_WIDTH=$(( COLUMNS - OPTIONS_WIDTH - TIME_WIDTH - STATUS_WIDTH )) -LINE_WIDTH=$(( COLUMNS - STATUS_WIDTH )) +# Initially setup terminal +resize_terminal -TIME_COL=$(( COLUMNS - TIME_WIDTH - STATUS_WIDTH )) -STATUS_COL=$(( COLUMNS - STATUS_WIDTH )) +# Call resize_terminal when terminal is being resized +trap "resize_terminal" WINCH # Define color for messages BOLD="\\033[1;39m"