I am writing an operators menu and would like to present the users with a default display with the status of apps / processes / tasks displayed.
Is there a way I can display a standard template each time the user chooses an option so that each screen is the same for each menu?
I can probably create a function that echo's the template around the executed commands but is there a way to set this up so the menu is always in the outer sector of the display / output and then doesn't matter what is displayed in the middle or inner section?
Hope i've explained ok?
Thanks
Chris
Note: If you are the author of this question and wish to assign points to any of the answers, please login first.For more information on assigning points ,click
here
Which scripting/programming language are you using?
This is a bit tedious to do efficiently using shell scripts.
You could print out your template, then move the cursor back up to the beginning of the content (using tput, see "man tput" for more info). When you are moving to another menu, first move the cursor back to the beginning of the content and fill the content area with space characters: they will overwrite the old menu. Then move the cursor back again to write in the new menu.
You can optimize this by making all your menu content lines the same length (by filling them out with spaces), then just overwriting the old menu with the new one.
If you use a more advanced scripting language (like perl) or a real programming language, you can use the functions of the curses library to help you. Often the curses library will auto-optimize the output for you, automatically moving the cursor around to change only the characters that need to be changed. It also has a concept of "windows", which is exactly what you need here.
a couple of years back, there was a related post here. one response included a set of awk scripts while another had a purely shell version. both used tput codes for hightlighting, and did pretty much what it sounds like you want to do.
I no longer have the link, it might be worth some searching around.
there also used to be a Tc/Tkl based menuing system available..that might have been at one of the GNU sites.