|
Home > Archive > Unix Programming > December 2005 > How can I do this
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| integer 2005-12-30, 7:57 am |
| Can some one provide me a link OR persuedo code to a hello world
program demostrating
hxxp://osx.hyperjeff.net/Showcase/screen_shots/2003.01.28.knotplot.jpg
a tabbed interface like that of the terminal app found on the left hand
side of the screen and any reference.
| |
| Barry Margolin 2005-12-30, 5:55 pm |
| In article <1135948505.932060.56390@g47g2000cwa.googlegroups.com>,
"integer" <can2two@hotmail.com> wrote:
> Can some one provide me a link OR persuedo code to a hello world
> program demostrating
> hxxp://osx.hyperjeff.net/Showcase/screen_shots/2003.01.28.knotplot.jpg
> a tabbed interface like that of the terminal app found on the left hand
> side of the screen and any reference.
I'm not sure what you're referring to. First, I changed your URL to use
"http" -- why did you deliberately munge it? When I went there, I
didn't see a terminal app with a tabbed interface. On the left side of
the screen I see two windows, KnotPlot and KnotPlot Command Window. On
the right side I see a GUI window with a tabbed interface, named
KnotPlot Control Panel.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
| |
| Chris F.A. Johnson 2005-12-30, 8:50 pm |
| On 2005-12-30, integer wrote:
> Can some one provide me a link OR persuedo code to a hello world
> program demostrating
> hxxp://osx.hyperjeff.net/Showcase/screen_shots/2003.01.28.knotplot.jpg
I think you meant http://....
> a tabbed interface like that of the terminal app found on the left hand
> side of the screen and any reference.
Do you mean the right-hand side of the screen?
This shell script creates a tabbed interface, but doesn't really do
anything; actions can be added in the info(), lsn(), psn() and
whon() functions. With a little effort, mouse control could also be
added. It requires some libraries which are at
http://cfaj.freeshell.org/funcs.tgz. Unpack them into the current
directory or a directory in your PATH.
#! /bin/bash
## Save as tabs-sh
progname=${0##*/}
case $progname in
*-sh) shx=-sh ;;
*) shx= ;;
esac
.. screen-funcs$shx
do_tabs()
{
printat 1 1
label=0
if [ $lastlabel -ne $selection ]
then
set_fgbg ${fgcolours[$selection]} ${bgcolours[$selection]}
cls
fi
while [ $label -le $lnum ]
do
set_fgbg ${fgcolours[$label]} ${bgcolours[$label]}
lab=${labels[$label]}
labwidth=${#lab}
space=$(( ($tabwidth - $labwidth) / 2 ))
printf "%${tabwidth}s" " "
printf "$cu_left%s$cu_right" $(( $labwidth + $space )) "$lab" $space
lastlabel=$label
label=$(( $label + 1 ))
done
printf "$NA$cle"
date
set_fgbg ${fgcolours[$selection]} ${bgcolours[$selection]}
eval "${commands[$selection]}"
}
info()
{
printat 10 10
put_block "This is a demonstration of using tabs in a shell script." \
"" "You can move from tab to tab with the TAB key" \
"or with 'r' and 'l'" "" "Press 'q' to exit"
}
lsn()
{
printat 10 10
list=( * )
put_block "${list[@]:0:10}"
}
psn()
{
local IFS=$NL
printat 10 10
put_block $( ps | head -10)
}
whon()
{
local IFS=$NL
printat 10 10
put_block $( who | head -10)
}
bgcolours=( $white $magenta $cyan $yellow )
fgcolours=( $black $white $black $black )
labels=( Intro Files Procs Users )
commands=( info lsn psn whon )
tabwidth=10
set_fgbg ${fgcolours[0]} ${bgcolours[0]}
cls
lnum=${#labels[@]}
lmax=$(( $lnum - 1 ))
selection=0
lastlabel=$(( $selection + 1 ))
printf "$cu_invis"
while :
do
do_tabs
get_key s
printat 1 50 "$s"
case $s in
q) break ;;
"$TAB"| r) selection=$(( $selection + 1 )) ;;
l) selection=$(( $selection - 1 )) ;;
esac
if [ $selection -ge $lnum ]
then
selection=0
elif [ $selection -lt 0 ]
then
selection=$lmax
fi
done
--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
|
|
|
|
|