% interface=en modes=icon,screen

\usemodule[abr-02]

\logo [METAPOST] {MetaPost}
\logo [METAFUN]  {MetaFun}

\setupcolors
  [state=start]

\setuplayout
  [footer=0pt,
   width=middle,
   height=middle]

\setupencoding[default=ec]
\usetypescript[fourier][ec]
\setupbodyfont[fourier]

\setuphead
  [chapter]
  [page=,
   after=\blank]

\setupwhitespace
  [big]

\setuptyping
  [margin=yes]

\definecolor[gray][s=.2,t=.5,a=1]

\startuseMPgraphic{TitlePage}{darkness}
  StartPage ;

  numeric factor   ; factor   := 1/3 ;
  numeric multiple ; multiple := PaperHeight/PaperWidth ; % 1.6 ;
  numeric stages   ; stages   := multiple/16 ; % .1 ;
  numeric darkness ; darkness := \MPvar{darkness} ;
  def Scaled(expr s, m) =
    if m = 1 :
      scaled (2*s*PaperWidth)
    else :
      xscaled (2*s*PaperWidth) yscaled (2*s*PaperHeight)
    fi
  enddef ;

  fill Page withcolor (factor*white) ;

  fill fullcircle scaled (multiple*PaperWidth) shifted llcorner Page withcolor (factor*red) ;
  fill fullcircle scaled (multiple*PaperWidth) shifted ulcorner Page withcolor (factor*green) ;
  fill fullcircle scaled (multiple*PaperWidth) shifted urcorner Page withcolor (factor*blue) ;
  fill fullcircle scaled (multiple*PaperWidth) shifted lrcorner Page withcolor (factor*yellow) ;

  for i = llcorner Page, ulcorner Page, urcorner Page, lrcorner Page :
    for j = 0 step stages until (10*stages-eps) : % or .8
      fill fullcircle Scaled(j,1) shifted i withcolor transparent(1,\MPvar{darkness}*(1-j),white) ;
    endfor ;
  endfor ;

  draw Page withpen pencircle scaled .1PaperWidth withcolor transparent(1,.5,.5white) ;

  StopPage
\stopuseMPgraphic

\startmode[icon,screen]

  \setuppapersize[S66][S66]

  \setupbodyfont[10pt]

\stopmode

\startmode[icon]

  \starttext

  \startTEXpage
     \useMPgraphic{TitlePage}{darkness=0.4}
  \stopTEXpage

  \stoptext

\stopmode

\starttext

% title page

\definelayer
  [TitlePage]
  [width=\paperwidth,
   height=\paperheight]

\setlayer
  [TitlePage]
  {\useMPgraphic{TitlePage}{darkness=1}}

\setlayerframed
  [TitlePage]
  [preset=rightbottom,
   hoffset=.1\paperwidth,
   voffset=.1\paperwidth]
  [align=left,
   width=\hsize,
   frame=off,
   foregroundcolor=gray]
  {\definedfont[SerifBold sa 10]SciTE\endgraf
   \definedfont[SerifBold sa 2.48]IN CONTEXT\kern.25\bodyfontsize}

\startTEXpage
  \tightlayer[TitlePage]
\stopTEXpage

% main text

\chapter{About \SCITE}

\SCITE\ is a source code editor written by Neil Hodgson. After playing with several
editors we decided that this editor was quite configurable and extendible. At \PRAGMA\
we use \TEXEDIT, an editor we wrote long ago in \MODULA\ as well as a platform
independent reimplementation called \TEXWORK\ written in \PERLTK. Although these
editors provide some functionality not present in \SCITE, we've decided to use \SCITE\
because it frees us from maintaining the other ones. In due time we will write some
extensions for \SCITE\ to fill in the gaps using the buitl in \LUA\ capabilities.

For those who want to configure an editor, it may make sense to look into the the
\SCITE\ property files that ship with \CONTEXT, especially:

\starttyping
context.properties
\stoptyping

Here we define some menu entries and keybinding that may make sense in other
editing environments as well.

\chapter{Installing SCITE}

Installing \SCITE\ is straightforward. We are most familiar with \MSWINDOWS\ but
for other operating systems installation is not much different. First you need
to fetch the archive from:

\starttyping
www.scintilla.org
\stoptyping

The \MSWINDOWS\ binaries are zipped in \type {wscite.zip}, and you can unzip this
in any directory you want as long as you make sure that the binary ends up in your
path or as shortcut on your desktop. So, say that you install \SCITE\ in

\starttyping
c:\scite\wscite
\stoptyping

You need to add this path to your local path definition.

For \UNIX, one can take a precompiled version as well. Here we need to split the
set of files into:

\starttyping
/usr/bin
/usr/share/scite
\stoptyping

The second path is hard coded in the binary.

If you want to use \CONTEXT, you need to copy the relevant files from

\starttyping
<cont-tmf.zip>/context/data
\stoptyping

to the path were \SCITE\ expects property (\type (*.properties) files.

In addition, you need to copy the following \LUA\ script to the
same location:

\starttyping
<cont-tmf.zip>/scripts/context/lua/scite-ctx.lua
\stoptyping

After this, things should run as expected (given that \TEX\ runs at the
console as well).

In order to run the commands needed, we assume that the following programs
are installed:

\startitemize[packed]
\item tidy (for quick and dirty checking of \XML\ files)
\item xsltproc (for converting \XML\ files into other formats)
\item acrobat (for viewing files)
\item ghostview (for viewing files, use gv on \UNIX)
\item rxvt (a console, only needed on \UNIX)
\stopitemize

When all the files are present, you need to make sure that the right
properties are loaded. You can do that by including the following line
at the end of one of the global or user properties files:

\starttyping
import context.properties
\stoptyping

In order for the \type {--autopdf} switch to work well under \UNIX, you need
to open acroread first. You can turn off auto opening of the result file by
adding  the following line to one of your local properties files:

\starttyping
name.texexec.flag.pdfopen=
\stoptyping

If you want to use the Latin Modern Fonts, you can best install the file

\starttyping
<cont-tmf.zip>/fonts/truetype/hoekwater/lm/LMTypewriter10-Regular.ttf
\stoptyping

\chapter{The \TeX\ lexer}

\SCITE\ provides several so called lexers. A lexer is responsible for highlighting
the syntax of your document. The way a \TEX\ file is treated is configured in the
file:

\starttyping
tex.properties
\stoptyping

You can edit this file to your needs using the menu entry under \type {options} in
the top bar. In this file, the following settings apply to the \TEX\ lexer:

\starttyping
lexer.tex.interface.default=0
lexer.tex.use.keywords=1
lexer.tex.comment.process=0
lexer.tex.auto.if=1
\stoptyping

The option \type {lexer.tex.interface.default} determines the way keywords are
highlighted. You can control the interface from your document as well, which
makes more sense that editing the configuration file each time.

\starttyping
% interface=all|tex|nl|en|de|cz|it|ro|latex
\stoptyping

The values in the properties file and the keywords in the preamble line have the
following meaning:

\starttabulate[|lT|lT|p|]
\NC 0 \NC all   \NC all commands (preceded by a backslash)                \NC \NR
\NC 1 \NC tex   \NC \TEX, \ETEX, \PDFTEX, \OMEGA\ primitives (and macros) \NC \NR
\NC 2 \NC nl    \NC the dutch \CONTEXT\ interface                         \NC \NR
\NC 3 \NC en    \NC the english \CONTEXT\ interface                       \NC \NR
\NC 4 \NC de    \NC the german \CONTEXT\ interface                        \NC \NR
\NC 5 \NC cz    \NC the czech \CONTEXT\ interface                         \NC \NR
\NC 6 \NC it    \NC the italian \CONTEXT\ interface                       \NC \NR
\NC 7 \NC ro    \NC the romanian \CONTEXT\ interface                      \NC \NR
\NC 8 \NC latex \NC \LATEX\ (apart from packages)                         \NC \NR
\stoptabulate

The configuration file is set up in such a way that you can easily add more
keywords to the lists. The keywords for the second and higher interfaces are
defined in their own properties files, like:

\starttyping
cont-nl-scite.properties
cont-en-scite.properties
latex-scite.properties
\stoptyping

The \CONTEXT\ distribution comes with a file:

\starttyping
context.properties
\stoptyping

as well as the interface specific files. There are two way to make sure that
the extra keywords are loaded. One way is to copy the following files to your
\SCITE\ properties path.

\starttyping
cont-*-scite.properties
latex-scite.properties
\stoptyping

The \type {*-scite} files define the keywords, while the later configures \SCITE\
for \CONTEXT. If you are no \CONTEXT\ user and want another brand of \TEX\ to be
processed, you can tweak the properties, or better: redefine some of them in your
\type {SciTEUser.properties}. For example plain \TEX\ users may like:

\starttyping
file.patterns.tex=*.tex;*.sty;
filter.tex=TeX|$(file.patterns.tex)|
lexer.$(file.patterns.tex)=tex
command.compile.$(file.patterns.tex)=
command.build.$(file.patterns.tex)=tex $(FileNameExt)
command.go.$(file.patterns.tex)=gv $(FileName).pdf
\stoptyping

On the other hand, \LATEX\ users may want:

\starttyping
file.patterns.latex=*.tex;*.sty;*.aux;*.toc;*.idx;
filter.latex=LaTeX|$(file.patterns.latex)|
lexer.$(file.patterns.latex)=tex
command.compile.$(file.patterns.latex)=
command.build.$(file.patterns.latex)=pdflatex $(FileNameExt)
command.go.$(file.patterns.latex)=gv $(FileName).pdf
\stoptyping

But, since you are a \CONTEXT\ user, you will need:

\starttyping
file.patterns.context=*.tex;*.tui;*.tuo;*.sty;
filter.context=ConTeXt|$(file.patterns.context)|
lexer.$(file.patterns.context)=tex
command.compile.$(file.patterns.context)=
command.build.$(file.patterns.context)=texexec --pdf $(FileNameExt)
command.go.$(file.patterns.context)=gv $(FileName).pdf
\stoptyping

The good news is that \CONTEXT\ users don't have to mess around with
the properties files! They have:

\starttyping
context.properties
\stoptyping

You can best put this file in the same path as \type
{SciTEUser.properties}. In this user file, you can add the following
line:

\starttyping
import context
\stoptyping

Now you have much more commands available (it makes sense to take a look
into this file). Beware: this setup assumes that you have the Latin Modern
Typewriter font on your system and that your operating system is aware of
that. If needed, you can add options (or local changed) after the line that
loads \type {context.properties}.

If you didn't copy the \type {cont-*.properties} files to the \SCITE\
properties path, you can put them in the same path as \type
{SciTEUser.properties}, in which you then have to add:

\starttyping
import cont-cz-scite
import cont-de-scite
import cont-en-scite
import cont-fr-scite
import cont-it-scite
import cont-nl-scite
import cont-ro-scite
import cont-xx-scite
import latex-scite
import context
\stoptyping

It may sound complicated but if you have done it once, you get the picture
quite well, and find out that \SCITE\ can easily be tuned to your local
preferences.

The \CONTEXT\ related properties files are part of the \CONTEXT\ distribution
and can be found in one of the following places:

\starttyping
../tex/texmf/context/data
../tex/texmf-local/context/data
\stoptyping

We generate the interface specific property files automatically from the
\CONTEXT\ interface definition files, while the \type {xx} file is
hand||crafted and contains missing or very special bits and pieces.

Back to the properties in \type {tex.properties}. You can disable keyword
coloring alltogether with:

\starttyping
lexer.tex.use.keywords=0
\stoptyping

but this is only handy for testing purposes. More interesting is that you can
influence the way comment is treated:

\starttyping
lexer.tex.comment.process=0
\stoptyping

When set to zero, comment is not interpreted as \TEX\ code and it will come out
in a uniform color. But, when set to one, you will get as much colors as a \TEX\
source. It's a matter of taste what you choose.

The lexer tries to cope with the \TEX\ syntax as good as possible and takes for
instance care of the funny \type {^^} notation. A special treatment is
applied to so called \type {\if}'s:

\starttyping
lexer.tex.auto.if=1
\stoptyping

This is the default setting. When set to one, all \type {\ifwhatever}'s will be
seen as a command. When set to zero, only the primitive \type {\if}'s will be
treated. In order not to confuse you, when this property is set to one, the
lexer will not color an \type {\ifwhatever} that follows an \type {\newif}.

\chapter{The \METAPOST\ lexer}

The \METAPOST\ lexer is set up slightly different from its \TEX\ counterpart,
first of all because \METAPOST\ is more a language that \TEX. As with the
\TEX\ lexer, we can control the interpretation of identifiers. The \METAPOST\
specific configuration file is:

\starttyping
metapost.properties
\stoptyping

Here you can find properties like:

\starttyping
lexer.metapost.interface.default=1
\stoptyping

Instead of editing the configuration file you can control the lexer with the
first line in your document:

\starttyping
% interface=none|metapost|mp|metafun
\stoptyping

The numbers and keywords have the following meaning:

\starttabulate[|lT|lT|p|]
\NC 0 \NC none           \NC no highlighting of identifiers   \NC \NR
\NC 1 \NC metapost or mp \NC \METAPOST\ primitives and macros \NC \NR
\NC 2 \NC metafun        \NC \METAFUN\ macros                 \NC \NR
\stoptabulate

Similar to the \TEX\ lexer, you can influence the way comments are handled:

\starttyping
lexer.metapost.comment.process=1
\stoptyping

This will interpret comment as \METAPOST\ code, which is not that useful
(opposite to \TEX, where documentation is often coded in \TEX).

The lexer will color the \METAPOST\ keywords, and, when enabled also additional
keywords (like those of \METAFUN). The additional keywords are colored and shown
in a slanted font.

The \METAFUN\ keywords are defined in a separate file:

\starttyping
metafun-scite.properties
\stoptyping

You can either copy this file to the path where you global properties files lives,
or put a copy in the path of your user properties file. In that case you need to
add an entry to the file \type {SciTEUser.properties}:

\starttyping
import metafun-scite
\stoptyping

The lexer is able to recognize \type {btex}||\type {etex} and will treat anything
in between as just text. The same happens with strings (between \type {"}). Both
act on a per line basis.

\chapter{The \XML\ exporter}

{\em The exporter will be descibed as soon as there are styles for processing
the \XML\ code. For the moment we stick to showing the schema.}

\typefile{scite.rng}

\chapter{Using \ConTeXt}

{\em As soon as they are stable, we will describe the \CONTEXT\ specific menu
commands and keybindings here.}

\chapter{Extensions (using \LUA)}

When the lua extensions are loaded, you will see a message
in the log pane that looks like:

\starttyping
-  see scite-ctx.properties for configuring info

-  ctx.spellcheck.wordpath set to ENV(CTXSPELLPATH)
-  ctxspellpath set to c:\data\develop\context\spell
-  ctx.spellcheck.wordpath expands to c:\data\develop\context\spell

-  ctx.wraptext.length is set to 65
-  key bindings:

Shift + F11   pop up menu with ctx options

Ctrl  + B     check spelling
Ctrl  + M     wrap text (auto indent)
Ctrl  + R     reset spelling results
Ctrl  + I     insert template
Ctrl  + E     open log file

-  recognized first lines:

xml   <?xml version='1.0' language='nl'
tex   % language=nl
\stoptyping

This message tells you what extras are available.

\chapter{Templates}

There is an experimental template mechanism. One option is to define
templates in a properties file. The property file \type
{scite-ctx-context} contains definitions like:

\starttyping
command.25.$(file.patterns.context)=insert_template \
$(ctx.template.list.context)

ctx.template.list.context=\
    itemize=structure.itemize.context|\
    tabulate=structure.tabulate.context|\
    natural TABLE=structure.TABLE.context|\
    use MP graphic=graphics.usemp.context|\
    reuse MP graphic=graphics.reusemp.context|\
    typeface definition=fonts.typeface.context

ctx.template.structure.itemize.context=\
\startitemize\n\
\item ?\n\
\item ?\n\
\item ?\n\
\stopitemize\n
\stoptyping

The file \type {scite-ctx-example} defines \XML\ variants:

\starttyping
command.25.$(file.patterns.example)=insert_template \
$(ctx.template.list.example)

ctx.template.list.example=\
    bold=font.bold.example|\
    emphasized=font.emphasized.example|\
    |\
    inline math=math.inline.example|\
    display math=math.display.example|\
    |\
    itemize=structure.itemize.example

ctx.template.structure.itemize.example=\
<itemize>\n\
<item>?</item>\n\
<item>?</item>\n\
<item>?</item>\n\
</itemize>\n
\stoptyping

For larger projects it makes sense to keep templates with the
project. In one of our projects we have a directory in the
path where the project files are kept which holds template files:

\starttyping
..../ctx-templates/achtergronden.xml
..../ctx-templates/bewijs.xml
\stoptyping

One could define a template menu like we did previously:

\starttyping
ctx.templatelist.example=\
    achtergronden=mathadore.achtergronden|\
    bewijs=mathadore.bewijs|\

ctx.template.mathadore.achtergronden.file=smt-achtergronden.xml
ctx.template.mathadore.bewijs.file=smt-bewijs.xml
\stoptyping

However, when no such menu is defined, we will automatically scan
the directory and build the menu without user intervention.

\chapter{Using \SCITE}

The following keybindings are available in \SCITE. Most of this list is taken from the
on line scite help pages.

\startbuffer[keybindings]
\starttabulate[|lT|p|]
\FL
\NC \rm \bf keybinding   \NC \bf meaning (taken from the Scite help file)                           \NC \NR
\ML
\NC Ctrl+Keypad+         \NC magnify text size                                                      \NC \NR
\NC Ctrl+Keypad-         \NC reduce text size                                                       \NC \NR
\NC Ctrl+Keypad/         \NC restore text size to normal                                            \NC \NR
\ML
\NC Ctrl+Keypad*         \NC expand or contract a fold point                                        \NC \NR
\ML
\NC Ctrl+Tab             \NC cycle through recent files                                             \NC \NR
\ML
\NC Tab                  \NC indent block                                                           \NC \NR
\NC Shift+Tab            \NC dedent block                                                           \NC \NR
\ML
\NC Ctrl+BackSpace       \NC delete to start of word                                                \NC \NR
\NC Ctrl+Delete          \NC delete to end of word                                                  \NC \NR
\NC Ctrl+Shift+BackSpace \NC delete to start of line                                                \NC \NR
\NC Ctrl+Shift+Delete    \NC delete to end of line                                                  \NC \NR
\ML
\NC Ctrl+Home            \NC go to start of document; \type{Shift} extends selection                \NC \NR
\NC Ctrl+End             \NC go to end of document; \type{Shift} extends selection                  \NC \NR
\NC Alt+Home             \NC go to start of display line; \type{Shift} extends selection            \NC \NR
\NC Alt+End              \NC go to end of display line; \type{Shift} extends selection              \NC \NR
\ML
\NC Ctrl+F2              \NC create or delete a bookmark                                            \NC \NR
\NC F2                   \NC go to next bookmark                                                    \NC \NR
\ML
\NC Ctrl+F3              \NC find selection                                                         \NC \NR
\NC Ctrl+Shift+F3        \NC find selection backwards                                               \NC \NR
\ML
\NC Ctrl+Up              \NC scroll up                                                              \NC \NR
\NC Ctrl+Down            \NC scroll down                                                            \NC \NR
\ML
\NC Ctrl+C               \NC copy selection to buffer                                               \NC \NR
\NC Ctrl+V               \NC insert content of buffer                                               \NC \NR
\NC Ctrl+X               \NC copy selection to buffer and delete selection                          \NC \NR
\ML
\NC Ctrl+L               \NC line cut                                                               \NC \NR
\NC Ctrl+Shift+T         \NC line copy                                                              \NC \NR
\NC Ctrl+Shift+L         \NC line delete                                                            \NC \NR
\NC Ctrl+T               \NC line transpose with previous                                           \NC \NR
\NC Ctrl+D               \NC line duplicate                                                         \NC \NR
\ML
\NC Ctrl+K               \NC find matching preprocessor conditional, skipping nested ones           \NC \NR
\NC Ctrl+Shift+K         \NC select to matching preprocessor conditional                            \NC \NR
\NC Ctrl+J               \NC find matching preprocessor conditional backwards, skipping nested ones \NC \NR
\NC Ctrl+Shift+J         \NC select to matching preprocessor conditional backwards                  \NC \NR
\ML
\NC Ctrl+[               \NC previous paragraph; \type{Shift} extends selection                     \NC \NR
\NC Ctrl+]               \NC next paragraph; \type{Shift} extends selection                         \NC \NR
\NC Ctrl+Left            \NC previous word; \type{Shift} extends selection                          \NC \NR
\NC Ctrl+Right           \NC next word; \type{Shift} extends selection                              \NC \NR
\NC Ctrl+/               \NC previous word part; \type{Shift} extends selection                     \NC \NR
\NC Ctrl+\               \NC next word part; \type{Shift} extends selection                         \NC \NR
\LL
\stoptabulate
\stopbuffer

\getbuffer[keybindings]

\chapter{Affiliation}

\starttabulate[|l|l|]
\NC author    \NC Hans Hagen                 \NC \NR
\NC copyright \NC PRAGMA ADE, Hasselt NL     \NC \NR
\NC more info \NC \type {www.pragma-ade.com} \NC \NR
\stoptabulate

\startstandardmakeup[headerstate=none,footer=none]

  \setuptabulate[before=,after=] \getbuffer[keybindings]

  \vfill

\stopstandardmakeup

\stoptext
