Slackware This Forum is for the discussion of Slackware Linux.
|
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
10-26-2013, 07:10 AM
|
#1
|
Member
Registered: Sep 2012
Posts: 372
Rep: 
|
Using shell script how can I move text lines up over an unchanging background
Just like it said. I need to be able to move several lines of text over an unchanging background. The rub is doing it with shell script.
I have tried several solutions with use of tput to no avail. However, I have not yet tried using tput capname and using the equivalent tput entry for the termcap equivalents. Does that work? Does anything work to do this?
|
|
|
10-26-2013, 08:07 AM
|
#2
|
LQ Addict
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,382
Rep: 
|
I don't know what you mean with an "unchanging background". Other than that you can use the terminfo capabilities of the treminfo database. I would write a few simple functions and variables.
Examples taken from an old text installer I wrote not using curses:
Code:
bold="\033[1m"; normal="\033[0m"; red="\033[0;31m"
underline_on="\033[4m";underline_off="\033[24m";
blink_on="\033[5m"; blink_off="\033[25m"
invisible_on="\033[25h"; invisible_off="\033[25l"
erase_end_of_screen="\033[0J"
up_delete_line () { tput cuu1; tput el; }
line_4_delete_eol () { tput cup 4 0; echo -e "\033[0J"; }
Of course see "man terminfo" for the codes.
Last edited by Didier Spaier; 10-26-2013 at 09:17 AM.
|
|
1 members found this post helpful.
|
10-26-2013, 08:16 AM
|
#3
|
Member
Registered: Sep 2012
Posts: 466
Rep: 
|
I would suggest you look at using something like dialog (what pkgtool uses). If you are looking to give the appearance of window; I am not clear on what you mean by background. You can certainly do a lot with escape sequences like Didier Spaier is suggesting as well, but you will find behavior changes a bit between the console, and various terminal emulators.
|
|
1 members found this post helpful.
|
10-26-2013, 08:41 AM
|
#4
|
Member
Registered: Jun 2002
Location: South Africa
Distribution: Custom slackware64-current
Posts: 308
Rep:
|
waddles, do you mean displaying text at an arbitrary position in the X root window or using something that reads user input?
If you mean the former, then have a look at xosd. You could probably also abuse conky to get the job done, although it has some additional dependencies (lua, tolua++, imlib2, giblib and feh).
|
|
1 members found this post helpful.
|
10-26-2013, 05:15 PM
|
#5
|
Member
Registered: Sep 2012
Posts: 372
Original Poster
Rep: 
|
@Didier: aware of tput & BTW U can save the escape typing by assigning to a variable. I will check on the tput el as I thing that is a terminfo usage but U can also do tput capname which is what I think that is where capname (terminfo) is el.
The unchanging background would be like and image of a flower or spacecraft as a background to moving foreground objects.
Thanks.
@fskmh: Thanks. What I am after is like above where I could create an image (actually foreground or background) that does not move as text rises from the bottom or descends from the top.
xosd looks close but not sure without testing. Will look into it further Thanks. Years ago the "COHERENT" a *nix OS, had capability to scroll text inside a field within an X-window but that does not seem to be a Linux/Slackware capability.
At least I can vary the background color to keep people awake during lectures.
@chemfire: I considered Dialog and Curses but don't know if that would allow auto-scrolling text.
I have thought of putting out a foreground image and re-echoing it before plunking down a line of text, then plunking down the image and 2 lines of text, the repeat for the 3rd line of text, etc. but that gets time consuming and after a few more lines of text. Reprinting 20+ lines of the "background" for the text will get SLOOOOOW.
LATER... BTW I have used esc[[col;row H before with Slacware but it no longer works with current versions.
Last edited by waddles; 10-30-2013 at 10:40 AM.
|
|
|
10-30-2013, 10:40 AM
|
#6
|
Member
Registered: Sep 2012
Posts: 372
Original Poster
Rep: 
|
I was thinking about something like xwd and xwud where I could take a "picture", save it, recall it, position new text on it, recall it, position more new text so that text would appear to scroll up over the "picture". I think using GIMP is a bit too much for what I am after and I would need to encode all the button pushes which could be lengthy.
|
|
|
10-31-2013, 03:28 AM
|
#7
|
Member
Registered: Sep 2012
Posts: 372
Original Poster
Rep: 
|
After struggling with this I have the solution that I required. However I would have liked to do it with a scroll region established with tput csr. For anyone interested:
Code:
#!/bin/sh
rm -f tstfil
rm -f tstfil2
rm -f tstfil3
# NOTE should make cursor invisible during display
echo "^[[40m" # Set BG to black
clear # goes with black
echo "^[[40m^[[1;37m" # Set FG (stars) to bold;white
knt=50 # Make 50 astronomic bodies
wid=`tput cols` # Get width of display screen
base=`tput lines` # Get bottom line of screen
# Create background scene of random stars
while [ $knt -gt 0 ]
do
y=`expr $RANDOM % $wid` # Create random y value
x=`expr $RANDOM % $base` # Create random x value
tput cup $x $y # Position for next astro body
if [ `expr $knt % 8` == 0 ]
then echo "^[[40m^[[1;31m¤^[[0m" # Red Dwarf star
else if [ `expr $knt % 10` == 0 ]
then echo "^[[40m^[[1;32m§^[[0m" # Green galaxy
else echo "^[[40m^[[1;37m.^[[0m" # Regular star
fi
fi
knt=`expr $knt - 1`
done
# FIND text to display at end of script and COPY it to a file
txln=`egrep "^>" spactst2 | wc -l`
tail -$txln spactst2 > tstfil # Put history into a file
# Create file of lines with ">" 1st character removed & centered
while read line
do
line=`echo ${line:1}` # Drop 1st char in line (>)
echo $line | \
sed -e :a -e "s/^.\{1,$wid\}$/ &/;ta" -e 's/\( *\)\1/\1/' \
>> tstfil2 # Output centered line to 2nd file
done < tstfil # Input file
# Create "WIPE" file of spaces & with size to fit history display
for i in $(seq 1 $base)
do
printf "%${wid}s\n" >> tstfil3 # Print line of spaces "$wid" wide
done
# Read successively more lines and as head moves up due to nl
# bump line start likewise
# NOTE: To prevent new lines merging with old ones this must start
# above the very last screen line and the positioning of lines
# using tput must be 1 above because of new line output.
echo "^[[40m^[[1;37m" # Make FG white and bold
n=`wc -l tstfil2 | cut -d" " -f1` # Get lines in 2nd file
base=`expr $base - 1` # Reset baseline prevents line push up
for i in $(seq 1 $n)
do
base=`expr $base - 1` # Moves up another line
tput cup $base 0
head -$i tstfil3 # Wipes current diplay of text plus 1
tput cup $base 0
head -$i tstfil2 # Text now 1 line longer
sleep 2
done
echo "^[[0m" # Return to default colors
exit
>In the year 1492 ol' Big Chris hit the boards and sailed off
>on a quest thought as foolish to our parents.
>Traveling to the Moon is as likely..
>Yet today here we are with flags and streamers.
>We welcome a much slimmer Christopher Columbus and his
>bounty.
>Let us hope that we will be less critical of
>our explorers and scientists when they reach for the stars
>or the Yetti.
Hope it helps somebody else.
|
|
|
All times are GMT -5. The time now is 01:29 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|