Operating System - HP-UX
1748249 Members
3870 Online
108760 Solutions
New Discussion юеВ

Re: Standard template / Menu

 
SOLVED
Go to solution
lawrenzo_1
Super Advisor

Standard template / Menu

Hi all,

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
hello
6 REPLIES 6
Matti_Kurkela
Honored Contributor
Solution

Re: Standard template / Menu

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.

Man pages on curses:
http://docs.hp.com/en/B2355-60127/curses_intro.3X.html
http://docs.hp.com/en/B2355-60127/curses.5.html
(+ man pages for each individual curses function)

If you are unfamiliar with the curses library and wish to use it, I'd recommend reading a good book on curses programming. For example:

John Strang, Programming with curses, O'Reilly, ISBN 0-937175-02-1

Ncurses is a free extended re-implementation of curses. Its documentation might be useful with regular curses too:
http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/

MK
MK
lawrenzo_1
Super Advisor

Re: Standard template / Menu

Hi Matti,

I am open to suggestions to be honest and will take a look at the curse stuff for sure ...

I am familair with tput so thanks for the suggestions.

Chris.


hello
OldSchool
Honored Contributor

Re: Standard template / Menu

Chris,

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.
James R. Ferguson
Acclaimed Contributor

Re: Standard template / Menu

Hi Chris:

For pure simplicity, this thread has several variations of shell-based menu scripts:

http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=993074

Regards!

...JRF...
OldSchool
Honored Contributor

Re: Standard template / Menu

And...one of the links in the post JRF noted to is the one I was referring to:

http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=984784
lawrenzo_1
Super Advisor

Re: Standard template / Menu

All,

Thank you very much - just what I was looking for and gives me something to work towards.

Regards

Chris
hello