Here's a patch attached which adds minor additional functionality to the re_store_present* scripts posted here today.
for the following scripts: re_store_present2 re_store_present3 re_store_present4 re_store_present5b the patch adds the command line argument -width n where n is a custom width you wish to trim to. adds glitchymess if n > terminal width. ie ./re_store_present3 -width 85 for the following scripts: re_store_present4 re_store_present5b the patch also adds a second command line argument -glitch where if specified, the escape sequence to erase characters left from the last v-scroll is replaced with "xxxx". the escape sequence itself has also been modified to work on the amd64 platform where it appeared to not work - don't know if this breaks things for x86 though. -james
diff -u re_store_present_scripts_org/re_store_present2 re_store_present_scripts/re_store_present2 --- re_store_present_scripts_org/re_store_present2 2009-05-26 21:56:27.000000000 +0100 +++ re_store_present_scripts/re_store_present2 2009-05-26 21:57:27.000000000 +0100 @@ -15,6 +15,14 @@ # clear the terminal display clear +width=80 +if [ "x$1" == "x-width" ]; then + # see http://linux.derkeiler.com/Mailing-Lists/SuSE/2008-05/msg00265.html + if [ $2 -eq $2 2> /dev/null ]; then + width=$2 + fi +fi + # below are the message in a secret coded form. # the tr command was used on the original message # and the output cut+pasted into this script. @@ -79,17 +87,17 @@ while true do echo -e $reset_cursor # -e enables processing of escape sequences. - echo "${msg1:0:80}" # most terminals are usually 80 chars wide. + echo "${msg1:0:width}" # most terminals are usually 80 chars wide. first=${msg1:0:1} # first character in msg. rest=${msg1:1:len1-1} # remainder of msg. msg1=${rest}${first} # reconstitute msg (so first is now last). echo -e "\n\n\n\n\n\n" # drop down a few lines - echo "${msg2:0:80}" # now do the same for second message... + echo "${msg2:0:width}" # now do the same for second message... first=${msg2:0:2} # (but now scrolling two chars each time) rest=${msg2:2:len2-2} msg2=${rest}${first} echo -e "\n\n\n\n\n\n\n\n\n\n\n" - echo "${msg3:0:80}" # and same for third message... + echo "${msg3:0:width}" # and same for third message... first=${msg3:0:3} # (scroll three chars each time) rest=${msg3:3:len3-3} msg3=${rest}${first} diff -u re_store_present_scripts_org/re_store_present3 re_store_present_scripts/re_store_present3 --- re_store_present_scripts_org/re_store_present3 2009-05-26 21:56:27.000000000 +0100 +++ re_store_present_scripts/re_store_present3 2009-05-26 21:57:27.000000000 +0100 @@ -15,6 +15,15 @@ # clear the terminal display clear +width=80 + +if [ "x$1" == "x-width" ]; then + # see http://linux.derkeiler.com/Mailing-Lists/SuSE/2008-05/msg00265.html + if [ $2 -eq $2 2> /dev/null ]; then + width=$2 + fi +fi + # below are the message in a secret coded form. # the tr command was used on the original message # and the output cut+pasted into this script. @@ -78,18 +87,18 @@ # resets the cursor position to the top-left of # the terminal reset_cursor="\033[0;0H"; -erase_line="\033[0;0K"; +erase_line="\033[0K"; ticker=0; while true do echo -e $reset_cursor # -e enables processing of escape sequences. - echo "${msg1:0:80}" # most terminals are usually 80 chars wide. + echo "${msg1:0:width}" # most terminals are usually 80 chars wide. first=${msg1:0:1} # first character in msg. rest=${msg1:1:len1-1} # remainder of msg. msg1=${rest}${first} # reconstitute msg (so first is now last). echo -e "\n" # drop down a few lines - echo "${msg2:0:80}" # now do the same for second message... + echo "${msg2:0:width}" # now do the same for second message... first=${msg2:0:2} # (but now scrolling two chars each time) rest=${msg2:2:len2-2} msg2=${rest}${first} @@ -106,7 +115,7 @@ # head alone provides, so capture it's output # and output it using echo ln=`head -n $src_line $0 | tail -n 1` - echo -n "$ln" # -n don't output newline + echo -n "${ln:0:width}" # -n don't output newline echo -e $erase_line # to erase remainder of line # this method avoids flickering due to erase+redraw. else diff -u re_store_present_scripts_org/re_store_present4 re_store_present_scripts/re_store_present4 --- re_store_present_scripts_org/re_store_present4 2009-05-26 21:56:27.000000000 +0100 +++ re_store_present_scripts/re_store_present4 2009-05-26 21:57:28.000000000 +0100 @@ -13,15 +13,38 @@ # #----------------------------------------------------------- +# clear the terminal display +clear + # reset cursor contains an escape-sequence which # resets the cursor position to the top-left of # the terminal when displayed via the echo -e command. -reset_cursor="\033[0;0H"; -erase_line="\033[0;0K"; +reset_cursor="\033[0;0H" +erase_line="\033[0K" +width=80 +glitch=0 +gpar=$1 +wpar=$1 +wparv=$2 + +if [ "x$1" == "x-glitch" ]; then + erase_line="xxxx" + wpar=$2 + wparv=$3 +fi + +if [ "x$wpar" == "x-width" ]; then + # see http://linux.derkeiler.com/Mailing-Lists/SuSE/2008-05/msg00265.html + if [ $wparv -eq $wparv 2> /dev/null ]; then + width=$wparv + fi + gpar=$3 +fi -# clear the terminal display -clear +if [ "x$gpar" == "x-glitch" ]; then + erase_line="xxxx" +fi # below are the message in a secret coded form. # the tr command was used on the original message @@ -83,8 +106,8 @@ fi # add spaces, line number, and the line together: fln="${spc}${src_line} ${ln}" - # remove characters in excess of 80... - src_arr[$src_line]=${fln:0:80} + # remove characters in excess of $width... + src_arr[$src_line]=${fln:0:width} let src_line=src_line+1 done @@ -115,7 +138,7 @@ while true do echo -e $reset_cursor # -e enables processing of escape sequences. - echo "${msg1:0:80}" # most terminals are usually 80 chars wide. + echo "${msg1:0:width}" # most terminals are usually 80 chars wide. first=${msg1:0:1} # first character in msg. rest=${msg1:1:len1-1} # remainder of msg. msg1=${rest}${first} # reconstitute msg (so first is now last). @@ -147,7 +170,7 @@ fi # now display the second message scrolling along the bottom echo -e "\n" - echo "${msg2:0:80}" + echo "${msg2:0:width}" first=${msg2:0:2} rest=${msg2:2:len2-2} msg2=${rest}${first} diff -u re_store_present_scripts_org/re_store_present5b re_store_present_scripts/re_store_present5b --- re_store_present_scripts_org/re_store_present5b 2009-05-26 21:56:27.000000000 +0100 +++ re_store_present_scripts/re_store_present5b 2009-05-26 21:57:39.000000000 +0100 @@ -13,15 +13,39 @@ # #----------------------------------------------------------- +# clear the terminal display +clear + # reset cursor contains an escape-sequence which # resets the cursor position to the top-left of # the terminal when displayed via the echo -e command. reset_cursor="\033[0;0H"; -erase_line="\033[0;0K"; +erase_line="\033[0K"; v_scroll_lines=8 -# clear the terminal display -clear +width=80 +glitch=0 +gpar=$1 +wpar=$1 +wparv=$2 + +if [ "x$1" == "x-glitch" ]; then + erase_line="xxxx" + wpar=$2 + wparv=$3 +fi + +if [ "x$wpar" == "x-width" ]; then + # see http://linux.derkeiler.com/Mailing-Lists/SuSE/2008-05/msg00265.html + if [ $wparv -eq $wparv 2> /dev/null ]; then + width=$wparv + fi + gpar=$3 +fi + +if [ "x$gpar" == "x-glitch" ]; then + erase_line="xxxx" +fi # below are the message in a secret coded form. # the tr command was used on the original message @@ -284,8 +308,8 @@ fi # add spaces, line number, and the line together: fln="${spc}${src_line} ${ln}" - # remove characters in excess of 80... - src_arr[$src_line]=${fln:0:80} + # remove characters in excess of width... + src_arr[$src_line]=${fln:0:width} let src_line=src_line+1 done @@ -317,7 +341,7 @@ while true do echo -e $reset_cursor # -e enables processing of escape sequences. - echo "${msg1:0:80}" # most terminals are usually 80 chars wide. + echo "${msg1:0:width}" # most terminals are usually 80 chars wide. first=${msg1:0:1} # first character in msg. rest=${msg1:1:len1-1} # remainder of msg. msg1=${rest}${first} # reconstitute msg (so first is now last). @@ -332,7 +356,7 @@ if [ "$line" -lt "1" ]; then echo elif [ "$line" -lt "$hist_line_count" ]; then - echo -n "${hist_arr[$line]}" + echo -n "${hist_arr[$line]:0:width}" echo -e $erase_line else echo @@ -351,7 +375,7 @@ fi # now display the second message scrolling along horizontal echo - echo "${msg2:0:80}" + echo "${msg2:0:width}" first=${msg2:0:2} rest=${msg2:2:len2-2} msg2=${rest}${first}
_______________________________________________ NetBehaviour mailing list [email protected] http://www.netbehaviour.org/mailman/listinfo/netbehaviour
