geany/m4/geany-status.m4
Jiří Techet ca21a8759a Don't use "echo -n" in shell scripts
The standard says:

If the first operand is -n, or if any of the operands contain a
backslash ( '\' ) character, the results are implementation-defined.

On OS X it simply prints the "-n" string and everything which follows,
including the newline.

Use printf instead.
2015-02-08 11:31:42 +01:00

46 lines
961 B
Plaintext

dnl GEANY_STATUS_ADD(description, value)
dnl Add a status message to be displayed by GEANY_STATUS_OUTPUT
AC_DEFUN([GEANY_STATUS_ADD],
[
_GEANY_STATUS="$_GEANY_STATUS
$1:$2"
])
dnl GEANY_STATUS_OUTPUT
dnl Nicely displays all messages registered with GEANY_STATUS_ADD
AC_DEFUN([GEANY_STATUS_OUTPUT],
[
# Count the max lengths
dlen=0
vlen=0
while read l; do
d=`echo "$l" | cut -d: -f1`
v=`echo "$l" | cut -d: -f2`
dl=${#d}
vl=${#v}
test $dlen -lt $dl && dlen=$dl
test $vlen -lt $vl && vlen=$vl
done << EOF
$_GEANY_STATUS
EOF
# Print a nice top bar
# description + ' : ' + value
total=`expr $dlen + 3 + $vlen`
for i in `seq 1 $total`; do printf '-'; done
echo
# And print the actual content
# format is:
# key1 : value1
# second key : second value
while read l; do
test -z "$l" && continue
d=`echo "$l" | cut -d: -f1`
v=`echo "$l" | cut -d: -f2`
printf '%-*s : %s\n' $dlen "$d" "$v"
done << EOF
$_GEANY_STATUS
EOF
])