
function f-tour ()

{

# The way back or out

tour-escape ()
{
head-col
echo
echo "Hit m to return to the Screen menu, x for a command prompt."
echo "Any other key to continue."
	white
	read -s -n 1 TOURESCAPE
	case $TOURESCAPE in
		m)
		f-tour
		;;
		x)
		f-prompt
		;;
		*)
		;;
	esac

}

clear

fig-col
figlet GNU"          "Screen
echo 

# Show attached and detached screens
if [ -d /var/run/screen/S-$USER ] && [ $(ls /var/run/screen/S-$USER | wc -l) -gt 0 ] ; then
	head-col
	echo "Currently available screens:"
	echo
	info-col
	screen -ls
fi

head-col
echo "The GNU Screen program - extra windows within a screen."

info-col
echo
echo "1: Introduction to Screen"
echo "2: Monitor Screen"
echo "3: Office Screen"
echo "4: File Manager Screen"
echo "5: Mail Screen"
echo "6: Music Screen"
echo "7: Plain Screen - Roll your Own"
echo "8: Reattach a Detached Screen"
echo
head-col
echo "Choose by number or letter."
echo
info-col
echo "f: Flip colours"
echo "m: INX menu"
echo "x: Give me a command prompt"
echo
f-ttynum
read -s -n 1 SCREEN
	case $SCREEN in
		1)
		clear
		head-col
		echo "Introduction to GNU Screen."
		info-col
		
cat  << EOS

The GNU Screen program allows you to have a collection of "sub-windows" within one 
virtual terminal. You can think of it as a kind of "tabbed workspace browser".
	
The fundamental key combination to remember when using Screen is
EOS
		head-col
		echo
		echo "			CTRL+a"
		echo
		info-col
cat  << EOS1
What this means is that almost any action you wish to perform in managing Screen 
is preceded by CTRL+a . For example, to switch from "tab" 0 to "tab" 3 you type
EOS1
		head-col
		echo
		echo "			CTRL+a 3"
		echo
		info-col
cat  << EOS2
... and so on.

The manual for Screen, and the INX cheat sheet for it, use C-a as an abbreviation.

Other useful starters:
	
	C-a c	"Creates" a new "window"
	C-a A	Lets you edit the name for your current "window (note capital "A")
	C-a d	Lets you "detach" the current set of windows ( "session" )

More on these and others will follow...
EOS2
white
tour-escape
clear
head-col
echo "An important note:"
info-col
cat << EOS3

Because C-a is taken by Screen as a control sequence, the usual command line shortcut

CTRL+A 

in bash, which takes the cursor to the beginning of the current line, does not
"work" in Screen. You need:

	C-a a

Although Screen can handle colours from some programs, the simpler 
colours of INX, and some other programs, will only be rendered in black and white.

To continue in this introduction, let's start a screen "session" and work from there...

EOS3
		white
		tour-escape
		f-sup
		screen -S intro -c $HOME/.screenrc-intro
		
		clear
		echo
		head-col
		
		echo "The Screen Introduction continues..."
		info-col
		echo
		echo "Looks like you got through the first session OK."			
cat  << EOS4

Now that you have a better idea of how Screen works, let's try an example of a "convenience"
session. This one is named "monitor" -  in fact if you want to, later, you can simply use the
command "monitor" to start it, assuming it isn't already running. In that case you would type
EOS4
		head-col
		
		echo
		echo "screen -r monitor"
		info-col
cat <<	EOS5

to "reattach" it.

When you have explored this "monitor" session, detach it with C-a d .
You will then see it in the inx Screen menu as a reminder that it is available.

In this introduction, though, you will be returned to the next part, rather than the menu.
So, hit a key to continue as prompted below...


EOS5
		white
		tour-escape
		f-sup
		monitor
		clear
		head-col
		
		echo
		echo "The final session in this introduction is a kind of \"grab bag\" ..."
		info-col
cat << 	EOS6
		
When you detach or exit the upcoming session of Screen, you should land back at the inx Screen menu.
You will see at least the "monitor" session showing as (Detached) at the top, assuming that
you did as suggested earlier.

Tip: You can re-attach detached screens by selecting them from the Screen menu, if they are 
included session names like "monitor" or "mailscreen".

EOS6
		white
		tour-escape
		f-sup
		screen -S tour -c $HOME/.screenrc-tour
		f-tour
		;;
		2)
		f-sup
		screen -ls | grep monitor > /dev/null 2>&1
		if [ $? = 0 ] ; then
			screen -r monitor
		else
			f-monitor
		fi
		f-tour
		;;
		3)
		f-sup
		screen -ls | grep office > /dev/null 2>&1
		if [ $? = 0 ] ; then
		  	screen -r office
		else
		        f-scroffice
		fi
		f-tour
		;;
		4)
		f-sup
		screen -ls | grep filemanage > /dev/null 2>&1
		if [ $? = 0 ] ; then
			screen -r filemanage
		else
			f-filemanage
		fi
		f-tour
		;;
		5)
		f-sup
		screen -ls | grep mailscreen > /dev/null 2>&1
		if [ $? = 0 ] ; then
			screen -r mailscreen
		else
			f-mailscreen
		fi
		f-tour
		;;
		6)
		f-sup
		screen -ls | grep music > /dev/null 2>&1
		if [ $? = 0 ] ; then
			screen -r music
		else
			f-music
		fi
		f-tour
		;;
		7)
		clear
		echo
		echo "Suggestion: Name your Screen session."
		echo
		echo "For example:"
		yellow
		echo
		echo "screen -S my-named-session"
		echo
		ownsession ()
		{
		info-col
		echo "Drop to a command prompt to roll your own session? (y/n)"
		read -s -n 1 ROLLYOUROWN
		case $ROLLYOUROWN in
			y)
			echo
			unbold
			white
			exit
			;;
			n)
			f-tour
			;;
			*)
			echo
			echo "Please type y for yes, n for no."
			sleep 2
			ownsession
			;;
		esac
		}
		ownsession
		;;
		8)
		echo
		yellow
		echo "Type the name of the screen you want to reattach."
		echo "You only need to type enough letters to avoid ambiguity."
		white
		echo
		read REATTACH
		screen -r "$REATTACH"
		f-tour
		;;
		f)
		export CALL=tour
		f-switch
		;;
		m)
		f-menu
		;;
		x)
		clear
		f-prompt
		;;
		*)
		echo
		head-col
		echo "I didn't understand that request - please try again."
		sleep 2
		f-tour
		;;
	esac


 }  
