% content=tex
%
% copyright=pragma-ade readme=readme.pdf licence=cc-by-nc-sa

\startenvironment ecommon

\usetypescript[palatino][texnansi]
\setupbodyfont[palatino,10pt]

\setuppapersize
  [S6][S6]

\setupinteractionscreen
  [option=max]

\setuplayout
  [topspace=10pt,
   backspace=10pt,
   width=middle,
   height=395pt,
   top=0cm,
   bottom=20pt,
   bottomdistance=15pt,
   header=0cm,
   footer=0cm]

\setupcolors
  [state=start]

\definecolor[green] [r=.2,g=.6,b=.2]
\definecolor[red]   [r=.6,g=.2,b=.2]
\definecolor[blue]  [r=.2,g=.2,b=.6]
\definecolor[yellow][r=1,g=1,b=.75]
\definecolor[gray]  [s=.4]
\definecolor[white] [s=.8]

\setupinteraction
  [state=start,
   menu=on,
   color=blue,
   contrastcolor=blue]

\setupbackgrounds
  [page]
  [background=color,
   backgroundoffset=5pt,
   backgroundcolor=gray]

\defineframedtext
  [result]
  [background=color,
   backgroundcolor=yellow, % white,
   backgroundoffset=5pt,
   strut=no,
   depthcorrection=no,
   frame=off,
   frameoffset=5.1pt,
   bottomframe=on,
   rulethickness=2.5pt,
   framecolor=gray,
   offset=0pt,
   width=\textwidth]

\setupbackgrounds
  [text][text]
  [background=color,
   backgroundcolor=yellow]

\setupbackgrounds
  [bottom][text]
  [background=color,backgroundcolor=red]

\def\StartExample%
  {\dostartbuffer[example][StartExample][StopExample]}

\def\StopExample%
  {\startresult[none]
   \getbuffer[example]
   \stopresult
   \bgroup
   \switchtobodyfont[9pt]
   \typebuffer[example]
   \egroup
   \page }

\setupinteractionmenu
  [bottom]
  [state=start,
   left=,
   right=,
   middle=\quad,
   style=\bfa\setstrut,
   color=yellow,
   contrastcolor=yellow]

\startinteractionmenu[bottom]
  \got [firstpage]     \getmarking[title] \\
  \hfill
  \got [firstpage]     begin \\
  \got [previouspage]  prev \\
  \got [nextpage]      next \\
  \got [CloseDocument] quit \\
\stopinteractionmenu

\setuptyping
  [color=blue,
   blank=halfline]

\definemarking[title]

\def\StartExamples#1%
  {\starttext
   \startstandardmakeup
   \blue
   \definedfont [RegularBold at 60pt]\setstrut
   \strut #1 \par
   \definedfont [RegularBold at 45pt]\setstrut
   \strut in \ConTeXt\
   \vfill
   \definedfont [RegularBold at 45pt]\setstrut
   \hfill
   \strut Examples
   \stopstandardmakeup
   \marking[title]{#1}}

\def\StopExamples
  {\stoptext}

\stopenvironment
