diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2016-02-26 02:02:50 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2016-11-18 07:05:52 +0100 |
commit | e7867fb0d9979c550e6e3d7597ece73b680c4af6 (patch) | |
tree | dc7a273abc5dd75ecdd94bc62419cd966f38b6d0 | |
parent | c0fe49457d37e4c51cd4fd829895a60ae24bc8af (diff) | |
download | sciteco-e7867fb0d9979c550e6e3d7597ece73b680c4af6.tar.gz |
implemented self-documenting (online) help system
* the new "?" (help) command can be used to look up
help topics.
* help topics are index from $SCITECOPATH/women/*.woman.tec
files.
* looking up a help topic opens the corresponding "womanpage"
and jumps to the position of the topic (it acts like an anchor
into the document).
* styling is performed by *.woman.tec files.
* Setting up the Scintilla view and munging the *.tec file
is performed by the new "woman.tes" lexer.
On supporting UIs (Gtk), womanpages are shown in a variable-width
font.
* Woman pages are usually not hand-written, but generated from manpages.
A special Groff post-processor grosciteco has been introduced for this
purpose. It is much like grotty, but can output SciTECO macros for styling
the document (ie. the *.woman.tec files).
It is documented in its own man-page.
* grosciteco also introduces sciteco.tmac - special Troff macros
for controlling the formatting of the document in SciTECO.
It also defines .SCITECO_TOPIC which can be used to mark up
help topics/terms in Troff markup.
* Woman pages are generated/formatted by grosciteco at compile-time, so
they will work on platforms without Groff (ie. as on windows).
* Groff has been added as a hard compile-time requirement.
* The sciteco(1) and sciteco(7) man pages have been augmented with
help topic anchors.
-rw-r--r-- | INSTALL | 4 | ||||
-rw-r--r-- | TODO | 55 | ||||
-rw-r--r-- | bootstrap.am | 16 | ||||
-rw-r--r-- | configure.ac | 19 | ||||
-rw-r--r-- | debian/control | 3 | ||||
-rw-r--r-- | doc/Makefile.am | 72 | ||||
-rwxr-xr-x | doc/generate-docs.tes | 1 | ||||
-rwxr-xr-x | doc/grosciteco.tes | 283 | ||||
-rw-r--r-- | doc/grosciteco.tes.1.in | 200 | ||||
-rwxr-xr-x | doc/htbl.tes | 6 | ||||
-rw-r--r-- | doc/sciteco.1.in | 34 | ||||
-rw-r--r-- | doc/sciteco.7.template | 169 | ||||
-rw-r--r-- | doc/sciteco.tmac | 65 | ||||
-rw-r--r-- | lib/Makefile.am | 10 | ||||
-rw-r--r-- | lib/lexers/woman.tes | 20 | ||||
-rw-r--r-- | sample.teco_ini | 8 | ||||
-rw-r--r-- | src/Makefile.am | 9 | ||||
-rw-r--r-- | src/help.cpp | 320 | ||||
-rw-r--r-- | src/help.h | 87 | ||||
-rw-r--r-- | src/parser.cpp | 2 |
20 files changed, 1319 insertions, 64 deletions
@@ -30,7 +30,9 @@ SciTECO Build and Runtime Dependencies * When choosing the GTK interface: * GTK+ v3.10 or later: http://www.gtk.org/ * GObject Builder v2.0.20 or later: http://www.jirka.org/gob.html - * Groff (only when formatting HTML manuals) + * GNU roff (groff): https://www.gnu.org/software/groff/ + Required at build-time, but it is already shipped on most + UNIX-like systems to format man pages. * Doxygen (only when generating developer documentation) These dependencies are bundled with the SciTECO Git repository @@ -14,6 +14,8 @@ Known Bugs: reverse of STYLE_DEFAULT. Perhaps we must call init_color() before initializing color pairs (currently done by Scinterm). + * Scinterm: The underline attribute is not applied properly + even on Urxvt where it obviously works. * session.save should save and reset ^R. Perhaps ^R should be mapped to a Q-Reg to allow [^R. Currently, saving the buffer session fails if ^R != 10. @@ -77,7 +79,23 @@ Features: commands. The current behaviour has few benefits. If a number is a regular command that stops parsing at the first invalid character in the current radix, we could write - hexadcimal constants like 16^R0BEEF^D (still clumsy...) + hexadcimal constants like 16^R0BEEF^D (still clumsy...). + (On the other hand, the radix is runtime state and parsing + must not depend on runtime state in SciTECO to ensure + parseability of the language.) + * Furthermore, this opens the possibility of floating point + numbers. The "." command does not take arguments, so it + could be part of the number syntax. This disallows constructs + like "23." to push 23 and Dot which have to be replaced by + "23,.". + * In the most simple case, all TECO numbers could be + floats/doubles with division/modulo having integer semantics. + A separate floating point division operator could be introduced + (e.g. ^/ with modulo being remapped to ^%). + * SciTECO could also be "dynamically" typed by using + integer and floating point types internally. + The operator decides how to interpret the arguments + and the return type. * Function key masking flag for the beginning of the command line. May be useful e.g. for solarized's F5 key (i.e. function key macros that need to terminate the command line as they @@ -114,6 +132,11 @@ Features: ED flags before everything else and --quiet. Command line arguments should then also be handled differently. + * For third-party macro authors, it is useful to know + the standard library path (e.g. to install new lexers). + There could be a --print-path option, or with the --quiet + and --stdout options, one could write: + sciteco -qoe 'G[$SCITECOPATH]' * The C/C++ lexer supports preprocessor evaluation. This is currently always enabled but there are no defines. Could be added as a global reg to set up defines easily. @@ -255,33 +278,7 @@ Documentation: * Code docs (Doxygen). It's slowly getting better... * clean up/fix generate-docs.tes generate-docs.tes could be turned into a general purpose script to - extract command and macro documentation from C and SciTECO code. + extract command and macro documentation from C and SciTECO code + (tedoc?). It should then be installed so it may be used by third-party macro library authors as well. - * An online help system based on manpages/Troff documents. - The internal commands and macro libraries are continued to be - documented using man-pages (perhaps generated via generate-docs.tes). - These troff documents can be augmented with SciTECO-specific tagging - troff macros which are invisible when processed by man/grotty. - Online documentation could be generated using a new dedicated - groff post-processor that generates SciTECO macros that fill a - buffer with the formatted text and style it. Let's call the roffed - documentation page a "womanpage" and the post-processor "womanizer". - While the source document will usually be man or mandoc, this would - allow writing online documentation using any troff macro package - and for simple documentations, the "womanpage" can be coded directly - in SciTECO. - SciTECO will support a new interactive-mode-only command (e.g. ^H) - that loads a "womanpage" by consulting a tag index, that is built - up when interactive mode boots and links a tag to a "womanpage" file - (allowing tab completion of course). - The "womanpage" macro not only builds up the formatted page when - executed but also a tag table that associates individual tags with - buffer positions. After the "womanpage" has been munged, SciTECO - consults this table to jump to the correct position. - The "womanizer" script is distributed as well, to allow third party - macro authors to properly document their macros by manpage and - only-help. - The nice thing about this scheme is that groff is not required - at run time since tagged womanpages are generated at build time. - Groff must be added as a build-time requirement, though. diff --git a/bootstrap.am b/bootstrap.am index 7c878c6..7ff35d3 100644 --- a/bootstrap.am +++ b/bootstrap.am @@ -2,10 +2,20 @@ # standard library library export SCITECOPATH=@top_srcdir@/lib +# This provides two implementations of SciTECO running +# on the host as build-time tools. +# $(SCITECO_MINIMAL) can be used during the build-process +# of the target SciTECO, but may have only limited support for +# the ES command (no symbolic identifiers). +# $(SCITECO_FULL) is a final version of SciTECO, but is only +# available after the binary has been built in src/ +# (ie. in SUBDIRS after src/). if BOOTSTRAP -BOOTSTRAP_SCITECO = @top_builddir@/src/sciteco-minimal$(EXEEXT) +SCITECO_MINIMAL = @top_builddir@/src/sciteco-minimal$(EXEEXT) +SCITECO_FULL = @top_builddir@/src/sciteco$(EXEEXT) else -BOOTSTRAP_SCITECO = @SCITECO@ +SCITECO_MINIMAL = @SCITECO@ +SCITECO_FULL = @SCITECO@ endif SUBST_MACRO = eb$<\e \ @@ -26,4 +36,4 @@ SUBST_MACRO = eb$<\e \ %/config.h: ; % : %.in - $(BOOTSTRAP_SCITECO) -e $$'$(SUBST_MACRO)' + $(SCITECO_MINIMAL) -e $$'$(SUBST_MACRO)' diff --git a/configure.ac b/configure.ac index dd37664..517f4a0 100644 --- a/configure.ac +++ b/configure.ac @@ -56,6 +56,7 @@ AC_PROG_CXX AC_PROG_CC AC_PROG_CC_C99 AC_PROG_GREP +AC_PROG_SED AC_PROG_INSTALL # Additionally required by the Scintilla build process: @@ -82,8 +83,20 @@ if [[ x$DATE = x ]]; then AC_MSG_ERROR([Required tool date not found!]) fi -# not necessarily required (depends on --enable-html-manual) +# SciTECO's online help system is based on Troff. +# Its `grosciteco` postprocessor practically only works with GNU roff. +# There are other good Troff implementations like Heirloom Troff, +# but the postprocessor relies on ditroff generating +# intermediate output in TTY/nroff mode. +# In the original UNIX Troff, nroff is a distinct implementation +# that does not work with postprocessors. +# +# Groff may also be used to generate HTML versions of +# sciteco(1) and sciteco(7). AC_CHECK_PROG(GROFF, groff, groff) +if [[ x$GROFF = x ]]; then + AC_MSG_ERROR([GNU roff required!]) +fi # not necessarily required (depends on --enable-developer-doc) AC_CHECK_PROG(DOXYGEN, doxygen, doxygen) @@ -295,10 +308,6 @@ AC_ARG_ENABLE(html-manual, AS_HELP_STRING([--enable-html-manual], [Generate and install HTML manuals using Groff [default=no]]), [html_man=$enableval], [html_man=no]) -if [[ $html_man = yes -a x$GROFF = x ]]; then - AC_MSG_ERROR([Enabled generating HTML manuals, but Groff cannot be found! - Try --disable-html-manual.]) -fi AM_CONDITIONAL(BUILD_HTMLMAN, [test $html_man = yes]) AC_ARG_ENABLE(developer-doc, diff --git a/debian/control b/debian/control index 4f7b3cd..f5821ab 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,8 @@ Section: editors Priority: optional Maintainer: Robin Haberkorn <robin.haberkorn@googlemail.com> Build-Depends: debhelper (>= 7.4), g++ (>= 4:4.4), - libglib2.0-dev (>= 2.28), ncurses-base, ncurses-term, libncurses5-dev + libglib2.0-dev (>= 2.28), ncurses-base, ncurses-term, libncurses5-dev, + groff-base Standards-Version: 3.9.2 Homepage: http://sciteco.sf.net/ Vcs-Browser: https://github.com/rhaberkorn/sciteco diff --git a/doc/Makefile.am b/doc/Makefile.am index 9909122..e63284a 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,33 +1,79 @@ # Make sure that $BOOTSTRAP_SCITECO and the SciTECO-based # substitutor is available. -# The target `sciteco` binary has already been built, -# but using $BOOTSTRAP_SCITECO ensures that we use -# a version running on the host machine when cross-compiling -# with --disable-bootstrap. include $(top_srcdir)/bootstrap.am -man_MANS = sciteco.1 -EXTRA_DIST = sciteco.1.in -CLEANFILES = sciteco.1 +# grosciteco is a troff postprocessor similar to grotty +# which can be used to produce SciTECO-friendly output +# (woman pages). +dist_bin_SCRIPTS = grosciteco.tes +# grosciteco, like many other postprocessors, works +# best with its own macro package. +# Unfortunately, there is no way to query the built-in +# Groff tmac path. +# Therefore, the "sciteco" macros are installed into +# SciTECO's pkgdatadir. Users can copy this file, set up +# environment variables like $GROFF_TMAC_PATH or pass +# the directory via `groff -M`. +dist_pkgdata_DATA = sciteco.tmac + +# Fix up the hash-bang line of grosciteco upon installation +# to refer to the installed sciteco binary. +# This takes --program-prefix into account. +install-exec-hook: + @SED@ -i "1s,#!.*sciteco,#!$(bindir)/`echo sciteco | @SED@ '$(transform)'`$(EXEEXT)," \ + $(DESTDIR)$(bindir)/grosciteco.tes + +womendir = $(scitecolibdir)/women + +women_DATA = grosciteco.tes.1.woman grosciteco.tes.1.woman.tec +CLEANFILES = grosciteco.tes.1.intermediate + +women_DATA += sciteco.1.woman sciteco.1.woman.tec +CLEANFILES += sciteco.1.intermediate + +women_DATA += sciteco.7.woman sciteco.7.woman.tec +CLEANFILES += sciteco.7.intermediate + +CLEANFILES += $(women_DATA) + +# NOTE: *.intermediate files are only generated since SciTECO scripts +# cannot currently read stdin, so the grosciteco postprocessor +# has to be run on a separate file. +%.woman %.woman.tec : %.intermediate grosciteco.tes + $(SCITECO_FULL) -m @srcdir@/grosciteco.tes \ + $(basename $<).woman $(basename $<).woman.tec $< + +%.intermediate : % sciteco.tmac + @GROFF@ -Z -Tascii -t -man -M@srcdir@ -msciteco $< >$@ + +man_MANS = grosciteco.tes.1 +EXTRA_DIST = grosciteco.tes.1.in + +man_MANS += sciteco.1 +EXTRA_DIST += sciteco.1.in man_MANS += sciteco.7 EXTRA_DIST += sciteco.7.template -CLEANFILES += sciteco.7 sciteco.7.in sciteco.7.htbl +CLEANFILES += sciteco.7.in sciteco.7.htbl SOURCES = $(wildcard @top_srcdir@/src/*.cpp) -EXTRA_DIST += generate-docs.tes htbl.tes +CLEANFILES += $(man_MANS) + +dist_noinst_SCRIPTS = generate-docs.tes htbl.tes %.in : %.template generate-docs.tes $(SOURCES) - $(BOOTSTRAP_SCITECO) -m @srcdir@/generate-docs.tes \ - $@ $< $(SOURCES) + $(SCITECO_FULL) -m @srcdir@/generate-docs.tes \ + $@ $< $(SOURCES) if BUILD_HTMLMAN -html_DATA = sciteco.1.html sciteco.7.html +html_DATA = grosciteco.1.html sciteco.1.html sciteco.7.html CLEANFILES += $(html_DATA) endif +# NOTE: The *.htbl files are only generated since SciTECO +# scripts cannot be integrated into pipelines easily yet. %.htbl : % htbl.tes - $(BOOTSTRAP_SCITECO) -m @srcdir@/htbl.tes $< $@ + $(SCITECO_FULL) -m @srcdir@/htbl.tes $< $@ %.html : %.htbl @GROFF@ -Thtml -man $< >$@ diff --git a/doc/generate-docs.tes b/doc/generate-docs.tes index 2d5af6a..ee4820c 100755 --- a/doc/generate-docs.tes +++ b/doc/generate-docs.tes @@ -38,6 +38,7 @@ j<fr .br ;> j<sMA;.u.t 1ua<."=1;'-a"A|1;'-a"V-1ua1;'r> qa"Sq.tj|.,q.txa.,q.td i +.SCITECO_TOPIC "Qa" .B Qa '> j<s[MC];.u.t-s[.,q.t-1xa .-1,q.td i diff --git a/doc/grosciteco.tes b/doc/grosciteco.tes new file mode 100755 index 0000000..d84c6ab --- /dev/null +++ b/doc/grosciteco.tes @@ -0,0 +1,283 @@ +#!/usr/bin/env sciteco -m +!* grosciteco.tes <output-woman> <output-tec> <input> *! + +!* Process command-line options *! +LR 0X[output-woman] 2LR 0X[output-tec] 2LR 0X[input] HK +EBQ[input] + +! skip whitespace characters ! +@#sw{ + <0A-^^ "N 1; ' :C;> +} + +!* skip N (string) arguments beginning with current one *! +@#sa{ + "~1'< + <0A-^^ "= 1; ' 0A-10"= 1; ' :C;> :M#sw + > +} + +!* get next integer argument, skipping it *! +@#gi{ + \ (0A-^^-"= :C ' <0A"D :C; | 1; '> :M#sw) +} + +!* skip end of command *! +@#sc{ + 0A-10"= :C ' +} + +0U[text.lines] 0U[pos.v] 0U[pos.h] + +!* move to (pos.h,pos.v) relative to origin, making space if necessary *! +@[move]{ [.n + U.n J + Q[pos.v]-Q[text.lines]"> + ZJ Q[pos.v]-Q[text.lines]<I^J> + Q[pos.v]U[text.lines] + | + Q[pos.v]L + ' + Q[pos.h]<.-Z"= I | 0A-10"= I | C' '> + Q.n<.-Z"= 1; ' 0A-10"= 1; ' D> +].n } + +@[style]{ [.l + U.l Q[font]-Q[default-style]"N + .-Q.lESSTARTSTYLING Q[font],Q.lESSETSTYLING + ' +].l } + +[topics] + +!* + * Special characters + * FIXME: Use UTF8 characters once available + *! +[glyphs.**]* +[glyphs.\-]- +[glyphs.aa]' +[glyphs.dq]" +[glyphs.hy]- +[glyphs.la]< +[glyphs.ra]> +[glyphs.lq]" +[glyphs.rq]" +[glyphs.rs]\ +[glyphs.+]+ + +!* process formatter commands *! +@[format]{ < + .-Z"= 1; ' + 0AU[cmd] C + Ocmd.U[cmd] + + !cmd.x! + :M#sw + 0AU[cmd] C + Ocmd.xU[cmd] + + !cmd.xT! + 2:M#sa :M#sc F< + !cmd.xr! + :M#sa :M#giU[res] :M#giU[res.h] :M#giU[res.v] :M#sc F< + !cmd.xi! + :M#sa :M#sc F< + !cmd.xF! + L F< + !cmd.xX! + :M#sw .(W).X.w + Ocmd.xXQ.w + !cmd.xXsciteco_topic! + !* + * FIXME: The buffer position of this topic might still + * change due to movement commands (esp. when formatting + * a table). Only the line+column should no longer change. + * Either store line+column or use markers. + *! + [* EB 0:M[move] .U.d ]* + :EU[topics]\.d: + C :X[topics] + L F< + !cmd.xXsciteco_tt! + [* EB 0:M[move] .U[ttstart] ]* + L F< + !cmd.xXsciteco_tt_end! + [* EB 0:M[move] + .-Q[ttstart]< + Q[ttstart]ESSTARTSTYLING Q[ttstart]ESGETSTYLEAT+16,1ESSETSTYLING + %[ttstart]> + ]* + L F< + !cmd.xXtty! + !cmd.xXdevtag! + L F< + + !cmd.xf! + :M#sa :M#giU.n Q.n+16U.#nt .(:M#sa).X[font] :M#sc + :Q[fonts.\.n]"F F< ' -U[fonts.\.n] + @:EU[styles]{\.#ntESSTYLESETFONTCourier^J} + Ocmd.xfQ[font] + !cmd.xfR! + Q.nU[default-style] + @:EU[styles]{16ESSTYLESETFONTCourier^J} + F< + !cmd.xfB! + @:EU[styles]{1,\.nESSTYLESETBOLD 1,\.#ntESSTYLESETBOLD^J} + F< + !cmd.xfBI! + @:EU[styles]{1,\.nESSTYLESETBOLD 1,\.#ntESSTYLESETBOLD^J} + !cmd.xfI! + @:EU[styles]{1,\.nESSTYLESETITALIC 1,\.#ntESSTYLESETITALIC^J} + @:EU[styles]{0EJ-1"= 1,\.nESSTYLESETUNDERLINE 1,\.#ntESSTYLESETUNDERLINE '^J} + F< + + !cmd.xt! + :M#sa :M#sc F< + !cmd.xs! + 1; + + !cmd.p! + :M#sw :M#gi Q[pos.v]U[origin.v] :M#sc F< + + !cmd.f! + :M#sw :M#giU[font] :M#sc F< + + !cmd.s! + :M#sw :M#gi :M#sc F< + + !cmd.V! + :M#sw :M#gi/Q[res.v]-1+Q[origin.v]U[pos.v] :M#sc F< + + !cmd.v! + :M#sw :M#gi/Q[res.v]%[pos.v] :M#sc F< + + !cmd.H! + :M#sw :M#gi/Q[res.h]U[pos.h] :M#sc F< + + !cmd.h! + :M#sw :M#gi/Q[res.h]%[pos.h] :M#sc F< + + !cmd.m! + :M#sw + 0AU[cmd] C + Ocmd.mU[cmd] + + !cmd.md! + :M#sc F< + + !cmd.D! + :M#sw + 0AU[cmd] C + Ocmd.DU[cmd] + + !cmd.DF! + :M#sw + 0AU[cmd] C + Ocmd.DFU[cmd] + + !cmd.DFd! + :M#sc F< + + !cmd.Dl! + :M#sw :M#gi/Q[res.h]+Q[pos.h]U.[to.h] :M#gi/Q[res.v]+Q[pos.v]U.[to.v] :M#sc + [* EB + Q.[to.h]-Q[pos.h]"= + ! vertical line ! + Q.[to.v]-Q[pos.v]"< Q[pos.v]U.v Q.[to.v]U[pos.v] | Q.[to.v]U.v ' + 1:M[move] I+ %[pos.v] + Q.v-Q[pos.v]< + 1:M[move] I| %[pos.v] + > + 1:M[move] I+ + Q.[to.v]U[pos.v] + | + ! horizontal line ! + Q.[to.h]-Q[pos.h]"< Q[pos.h]U.h Q.[to.h]U[pos.h] | Q.[to.h]U.h ' + 1:M[move] I+ %[pos.h] + Q.h-Q[pos.h]< + 1:M[move] I- %[pos.h] + > + 1:M[move] I+ + Q.[to.h]U[pos.h] + ' + ]* F< + + !cmd.t! + :M#sw .(:M#sa).X.w + [* EB :Q.w:M[move] + G.w :Q.w:M[style] ]* + :Q.w%[pos.h] :M#sc F< + + !cmd.C! + :M#sw .(:M#sa).X.w + [* EB 1:M[move] + G[glyphs.Q.w] 1:M[style] ]* :M#sc F< + + !cmd.c! + :M#sw 0AU.w C + [* EB 1:M[move] + G[glyphs.U.w] 1:M[style] ]* :M#sc F< + + !cmd.n! + :M#sw :M#gi :M#gi :M#sc F< + + !cmd.w! + :M#sc F< +> } + +!* + * Inline local macro invocations in [format] + * This speeds up runtime by 25% + *! +EQ[format] + J<FR:M[move]Q[move];> + J<FR:M[style]Q[style];> + J<FR:M#saQ#sa;> + J<FR:M#giQ#gi;> + J<FR:M#swQ#sw;> + J<FR:M#scQ#sc;> + !* + * Compress whitespace, kind of dangerous: + * J<FRS ;> + *! +Q*U* + +:M[format] + +!* + * Generate the styling instructions based on the styles + * of the womanpage buffer. The styles are configured according + * to their font positions (already in `styles`). + * Styles are NOT generated in `styles` immediately during + * formatting, since the buffer positions of text to style + * can still change with `move` operations that add whitespace. + * Also, here we can generate a minimal list of styling operations + * ending up with much smaller *.tec files. + * TODO: The size can still be improved by using SCI_SETSTYLINGEX + * if appropriate. + *! +EB J 0U#cs 0U#cd +< + .ESGETSTYLEATUs Qs"< Qs= ' + .-Z"< Qs-Q#cs"= C F< ' ' + Q#cs"N + .-Q#cd Ul + @:EU[styles]{\#cdESSTARTSTYLING \#cs,\lESSETSTYLING^J} + ' + QsU#cs .U#cd +:C;> + +!* + * Save the clear-text part of the document into <output-woman> + *! +EWQ[output-woman] + +EQ[styles] + +!* Generate topic index *! +J I!*Q[topics]*!^J + +EWQ[output-tec] + +-EX diff --git a/doc/grosciteco.tes.1.in b/doc/grosciteco.tes.1.in new file mode 100644 index 0000000..e890a96 --- /dev/null +++ b/doc/grosciteco.tes.1.in @@ -0,0 +1,200 @@ +.ds ST \\fB@PACKAGE_NAME@\\fP +. +. +.TH "grosciteco.tes" 1 \ + "@DATE@" \ + "@PACKAGE_NAME@ Version @PACKAGE_VERSION@" +. +. +.SCITECO_TOPIC grosciteco grosciteco.tes +.SH NAME +grosciteco \-\- +GNU roff post-processor for \*(ST +. +. +.SH SYNOPSIS +. +.SY grosciteco.tes +.I text_output +.I tec_output +.I input +.YS +. +. +.SH DESCRIPTION +. +\fBgrosciteco\fP is a post-processor for \fBGNU roff\fP which works +similar to \fBgroff\fP's \fBgrotty\fP post-processor and driver. +Similarily, \fBgrosciteco\fP is a plain-text formatter \(em but +since it lays out the document itself and is written in the \*(ST +language, it will generate an additional \*(ST macro that can be +executed to style the plain-text document. +.LP +.SCITECO_TOPIC woman women womanpage +The plain-text document will usually have the extension \(lqwoman\(rq +and the accompanying \*(ST macro will have the extension \(lqwoman.tec\(rq. +Both files combined are called \fIwomanpage\fP since they are commonly +\*(ST-formatted man pages. +.LP +Furthermore, \fIwomanpages\fP can be indexed by search terms +(called topics). +A per-file topic index is generated as part of the \(lqwoman.tec\(rq +output file. +Users of \fBgrosciteco\fP can define topics in \fBtroff\fP +markup using the \fBSCITECO_TOPIC\fP troff macro defined +in the \(lqsciteco.tmac\(rq macro package. +This macro package should always be loaded when processing +\fBtroff\fP documents which are going to be post-processed by +\fBgrosciteco\fP. +.LP +Preparing a \fIwomanpage\fP for display is usually performed +automatically by \*(ST's \(lqwoman.tes\(rq lexer definition +whenever you open a \(lq*.woman\(rq file in \*(ST. +\fIwomanpages\fP are recommended to be installed into a special +directory in \*(ST's standard library. +The \*(ST command \fB?\fP provides an online help feature +which gives fast access to properly-installed \fIwomanpages\fP. +It builds a global topic index of all \fIwomanpages\fP installed +in the \fB$SCITECOPATH/women\fP directory. +\fBgrosciteco\fP is thus a central component in providing +\*(ST's help system, in documenting internal commands, the +\*(ST standard library macros and third-party macro packages. +The generation of \fIwomanpages\fP at compile-time means +that no \fBtroff\fP is required by end users to browse +documentation within \*(ST. +. +. +.SH OPTIONS +. +.IP "\fItext_output\fP +The plain-text output file, e.g. \(lqgreat-macro.woman\(rq. +.IP "\fItec_output\fP +The \*(ST script that when executed after loading +\fItext_output\fP into a Scintilla view, styles that document. +It can be thought of as representing meta-information +for \fItext_output\fP. +In order to cooperate with the \(lqwoman\(rq lexer and +\*(ST's \fB?\fP command, its file name should be +\fItext_output\fP.tec, e.g. \(lqgreat-macro.woman.tec\(rq. +.IP "\fIinput\fP" +The \fIinput\fP file is in \fBtroff\fP's device-independant +output format. +. +. +.SH SPECIAL TROFF MACROS +. +.SCITECO_TOPIC sciteco.tmac tmac +\fBtroff\fP documents should be processed with the +\(lqsciteco.tmac\(rq macro package that also ships with +\*(ST. +It tweaks formatting for display in \*(ST (assuming +that the lexer system for \fIwomanpages\fP is in place) +and provides the following \fBtroff\fP macros that +can be called by documentation authors: +. +.TP +.TQ +\fB.SCITECO_TOPIC \fItopics...\fR +.SCITECO_TOPIC .SCITECO_TOPIC SCITECO_TOPIC +Defines one or more topics in \*(ST's help system. +Every topic must be in its own macro argument. +A \fItopic\fP can be looked up in \*(ST using +the \fB?\fItopic\fB$\fR command, but in case of +topic collisions, \*(ST will modify the topic name +to keep it unique. +The \fB?\fP (question mark) command will jump to the position +that corresponds to the macro call in \fBtroff\fP +markup. +Topics can and should only consist of printable characters, +so escape characters should be written in their up-caret +notation (e.g. \(lq^[\(rq instead of escape). +\*(ST expands control characters to their printabel form +when looking up terms. +.TQ +\fB.SCITECO_TT\fP [\fIline length\fP] +.SCITECO_TOPIC .SCITECO_TT SCITECO_TT +Marks the beginning of an area that must be formatted +in a monospaced font. +\fBgrosciteco\fP has only limited support for Troff font styles +and the font family used depends on the \*(ST UI used to +show the womanpage. +Since line drawing commands assume a TTY-like output device, +.B SCITECO_TT +should precede those sections of text (including the \fBtbl\fP +macro \fBTS\fP). +An optional temporary \fIline length\fP may also be specified +which is especially useful for tables. +.TQ +\fB.SCITECO_TT_END\fP [\fBSP\fP] +.SCITECO_TOPIC .SCITECO_TT_END SCITECO_TT_END +Marks the end of an area that must be formatted in a +monospaced font. +The optional \fBSP\fP keyword may be specified to skip one +line vertically (via troff's \fB.sp\fP request). +. +.LP +These public macros will be ignored if \(lqsciteco.tmac\(rq +is not loaded, so it is safe to use them in man pages +that are also installed into the system. +.LP +Note that \(lqsciteco.tmac\(rq is not installed into the +standard \fBGNU roff\fP macro search directories, but into +\*(ST data directory at \(lq@pkgdatadir@\(rq. +It must thus be moved or linked manually into one of the +search paths, or the data dir must be added to the search +paths. +Alternatively, you may also add it to the \fBgroff\fP +command line with the \fB-M\fP option. +. +. +.SH EXAMPLES +. +The following UNIX shell commands will generate the \fIwomanpage\fP for +a \*(ST macro package with a man page called +\fBgreat-macro.tes\fP(7sciteco): +. +.RS +.EX +.SCITECO_TT +groff -Z -Tascii -man -M@pkgdatadir@ -msciteco \\ + great-macro.tes.7sciteco >great-macro.tes.7sciteco.intermediate +grosciteco.tes great-macro.tes.7sciteco.woman great-macro.tes.7sciteco.woman.tec \\ + great-macro.tes.7sciteco.intermediate +.SCITECO_TT_END +.EE +.RE +.LP +The resulting files should be installed to +.B "@scitecolibdir@/women" +(or wherever \fB$SCITECOPATH\fP points to at runtime) +to make the files accessible in \*(ST's online-help system. +. +. +.SH BUGS +. +\fBgrosciteco\fP is quite slow, although this is a \*(ST issue. +. +. +.SH SEE ALSO +. +.TP +\*(ST invocation and help on its environment variables: +.BR sciteco (1) +.TP +Language reference including additional information on the \fB?\fP command: +.BR sciteco (7) +.TP +The \fBGNU roff\fP front end program: +.BR groff (1) +.TP +The \fBGNU roff\fP \(lqman\(rq macros for writing man pages: +.BR groff_man (7) +. +. +.SH AUTHOR +. +This manpage and the \*(ST program was written by +.MT robin.haberkorn@googlemail.com +Robin Haberkorn +.ME . +\# EOF
\ No newline at end of file diff --git a/doc/htbl.tes b/doc/htbl.tes index 8998d79..4118e55 100755 --- a/doc/htbl.tes +++ b/doc/htbl.tes @@ -1,6 +1,6 @@ -#!/usr/bin/sciteco -m -! ./htbl.tes <input> <output> ! -! Troff tbl "drop-in" replacement ! +#!/usr/bin/env sciteco -m +!* htbl.tes <input> <output> *! +!* Troff tbl "drop-in" replacement *! LR 0X#in 2LR 0X#ou EBQ#in EB -EF diff --git a/doc/sciteco.1.in b/doc/sciteco.1.in index bb7d29b..e6c4d8a 100644 --- a/doc/sciteco.1.in +++ b/doc/sciteco.1.in @@ -13,6 +13,7 @@ Scintilla-based \fBT\fPext \fBE\fPditor and \fBCO\fPrrector . .SH SYNOPSIS . +.SCITECO_TOPIC "sciteco" .SY @PACKAGE@ .OP "-h|--help" .OP "-e|--eval" macro @@ -37,6 +38,7 @@ It is geared towards UNIX-like operating systems but also natively supports Microsoft Windows NT\*(Tm. . .LP +.SCITECO_TOPIC mung When executed, \*(ST mungs (executes) the TECO macro stored in the file specified by the .B "--mung" @@ -48,14 +50,20 @@ mode, allowing the user to write stand-alone TECO scripts. Only when munging files as opposed to other means of executing macros, the first line is ignored if it begins with \(lq#!\(rq. Therefore under UNIX-like operating systems, TECO macro files may be -invoked as scripts by using a Hashbang line like +invoked as scripts by using a Hash-Bang line like +.\" FIXME: We'd like to include #! as a topic, but ! character are currently +.\" not allowed since they are not escaped correctly. +.SCITECO_TOPIC scripting .RS +.SCITECO_TT .EX #!@bindir@/sciteco -m .EE +.SCITECO_TT_END .RE . .LP +.SCITECO_TOPIC argv arguments Upon startup \*(ST's buffer ring contains only one unnamed empty buffer. All command line arguments after the \*(ST options are passed as .I arguments @@ -101,12 +109,14 @@ are prefixed with a string signifying the message's severity. In interactive mode, messages are also shown in a GUI-dependant manner. .IP \(bu +.SCITECO_TOPIC batch In batch mode, any \*(ST command failure will terminate the program. A full stack trace of \*(ST macro invocations will be printed to \fIstderr\fP and the process' return code will signify failure. In interactive mode, \*(ST will \(lqrub out\(rq any character resulting in a command failure. .IP \(bu +.SCITECO_TOPIC interactive The interactive mode enables character rub-out and thus undoing of command side-effects. Therefore code runs significantly slower in interactive mode @@ -139,8 +149,10 @@ option. .SH OPTIONS . .IP "\fB-h\fR, \fB--help\fR" +.SCITECO_TOPIC "-h" "--help" Display a short help text on the console. .IP "\fB-e\fR, \fB--eval\fR \fImacro" +.SCITECO_TOPIC "-e" "--eval" Evaluate (execute) .I macro specified as a command-line option. @@ -149,10 +161,12 @@ If the option is specified, the .B \-\-mung option has no effect. .IP "\fB-m\fR, \fB--mung\fR \fIfile" +.SCITECO_TOPIC "-m" "--mung" Mung \fIfile\fP. Default is .IR $SCITECOCONFIG/.teco_ini . .IP "\fB--no-profile\fP" +.SCITECO_TOPIC "--no-profile" Do not mung any profile. This leaves the editor in interactive mode with default settings just as if no profile existed or like when @@ -167,12 +181,14 @@ Execute \(lqsciteco --help\(rq for more details. . . .SH EXIT STATUS +.SCITECO_TOPIC status . \*(ST will return a non-null exit code if an error occurred during batch mode processing. . . .SH ENVIRONMENT +.SCITECO_TOPIC environment . Before \*(ST executes any macro, all of the variables in the process environment are inserted into the global Q-Register table. @@ -196,6 +212,7 @@ these registers. The following environment variables and registers are initialized with default values by \*(ST if they are unset: .TP +.SCITECO_TOPIC "$HOME" "HOME" .B HOME Home directory of the current user. This may be used e.g. by the \fBFG\fP command and for @@ -208,6 +225,7 @@ Initialization of this variable ensures that the \(lq$HOME\(rq Q-Register is available even on Windows and the home directory can always be re-configured. .TP +.SCITECO_TOPIC "$SHELL" "SHELL" "$COMSPEC" "COMSPEC" .BR SHELL " or " COMSPEC Path of the command interpreter used by \fBEG\fP and \fBEC\fP commands if UNIX98 shell emulation is \fIdisabled\fP. @@ -217,6 +235,7 @@ Both variables are usually already set in the process environment but are initialized to \(lq/bin/sh\(rq or \(lqcmd.exe\(rq should they nevertheless be unset. .TP +.SCITECO_TOPIC "$SCITECOCONFIG" "SCITECOCONFIG" .B SCITECOCONFIG Path where \*(ST looks for configuration files. For instance, this is the path of the default profile. @@ -228,6 +247,7 @@ on Windows. On other platforms, this variable defaults to some other user-specific configuration directory. .TP +.SCITECO_TOPIC "$SCITECOPATH" "SCITECOPATH" .B SCITECOPATH Standard library macro path. Macros can expect to find standard library macros in this @@ -253,6 +273,7 @@ Additionally \*(ST may be influenced by the .UR https://developer.gnome.org/glib/stable/glib-running.html environment variables accessed by glib .UE . +.SCITECO_TOPIC "$TERM" "TERM" On a Curses UI, there are other important environment variables like \fBTERM\fP, \fBLINES\fP, \fBCOLUMNS\fP and \fBESCDELAY\fP that may be accessed when \*(ST enters interactive mode. @@ -269,6 +290,7 @@ can be modified in the profile macro. \*(ST currently reacts to the following signals or uses them internally: .TP +.SCITECO_TOPIC "SIGINT" .B SIGINT Interrupts the currently running macro. The character resulting in the macro execution will fail @@ -285,6 +307,7 @@ Note that this signal can usually also be generated when pressing This is useful for GUIs that do not yet support interruptions directly. .TP +.SCITECO_TOPIC "SIGTERM" .B SIGTERM Try to gracefully shut down \*(ST. In batch mode this only interrupts the currently running macro @@ -298,6 +321,7 @@ program termination or user-programmed behaviour. .SH FILES . .TP +.SCITECO_TOPIC ".teco_ini" "profile" .B $SCITECOCONFIG/.teco_ini Default profile macro. .TP @@ -309,6 +333,7 @@ and opening files specified on the command line. .B $SCITECOPATH/*.tes Standard library macros. .TP +.SCITECO_TOPIC savepoint .BI .teco- n - filename ~ Save point files created by \*(ST when saving files during interactive execution have this format. @@ -316,6 +341,7 @@ On Windows, these files have the hidden attribute set. Savepoint files are temporary and should be ignored by version control systems, etc. .TP +.SCITECO_TOPIC ".teco_session" session .B $SCITECOCONFIG/.teco_session Macro storing the default buffer session. This is not written by \*(ST itself, but by the @@ -324,11 +350,13 @@ When the \(lqsession.vcs\(rq macro is used, these files will also be created in the roots of Git, Mercurial and Subversion repositories or working copies. .TP +.SCITECO_TOPIC ".teco_css" .B $SCITECOCONFIG/.teco_css When using the Gtk UI, this will be the location of a CSS file that can be used to apply \*(ST color schemes to the entire UI and to do other style customizations. .TP +.SCITECO_TOPIC "fallback.css" .B @pkgdatadir@/fallback.css When using the Gtk UI, this is a fallback stylesheet in case @@ -344,6 +372,10 @@ It may also be used as a template for Language reference: .BR sciteco (7) .TP +The \fBtroff\fP post-processor for \*(ST, including +information on how to write \(lqwomanpages\(rq: +.BR grosciteco (1) +.TP Homepage: .UR @PACKAGE_URL@ \*(ST at Sourceforge diff --git a/doc/sciteco.7.template b/doc/sciteco.7.template index aa7ae81..f3f5b48 100644 --- a/doc/sciteco.7.template +++ b/doc/sciteco.7.template @@ -7,12 +7,14 @@ "@PACKAGE_NAME@ Version @PACKAGE_VERSION@" . . +.SCITECO_TOPIC language .SH NAME @PACKAGE@ \-\- Language reference for the \*(ST text editor and language . . .SH INTRODUCTION AND PHILOSOPHY +.SCITECO_TOPIC philosophy . \*(ST is a powerful editor and interactive programming language following an unique paradigm of text editing. @@ -38,6 +40,7 @@ operations, \*(ST supports undoing and redoing on a per-character, per-command or even user-configurable level undoing most of the side-effects on the overall editor state. .LP +.SCITECO_TOPIC TECO \*(ST is a member of the TECO family of text editor languages, invented by Dan Murphy in the 1960s. TECO was initially a purely command-driven editor that evolved @@ -47,6 +50,7 @@ Emacs later became an independent program that eventually dropped TECO as its scripting language in favour of Lisp. \*(ST is not the first attempt to devise a TECO-based interactive screen editor. +.SCITECO_TOPIC "Video TECO" It is very similar to \fIVideo TECO\fP, a little known editor that pioneered the concept. When \fIVideo TECO\fP wanted to \(lqoutdo classic TECOs in every way\(rq, @@ -94,6 +98,7 @@ Keys with a printable representation (letters, digits and special characters) are translated to their printable representation. Shift-combinations automatically result in upper-case letters. .IP 2. +.SCITECO_TOPIC ctrl Control-combinations (e.g. CTRL+A) are translated to control codes, that is a code smaller than 32. The control code can be calculated by stripping the seventh bit @@ -128,12 +133,15 @@ next subsection. . .SS Function Key Macros . +.SCITECO_TOPIC "function key" By default function keys except Escape, Backspace and Return are ignored by \*(ST. By setting bit 6 of the \fBED\fP flag variable, function key handling is enabled: .EX +.SCITECO_TT 0,64ED +.SCITECO_TT_END .EE This is usually performed in the editor profile. With certain interfaces (curses) after enabling function keys, @@ -149,61 +157,83 @@ These are Q-Register strings inserted into the command stream keys (or combinations) are pressed. The following list of Function Key Macro registers are supported: .TP 9 +.SCITECO_TOPIC ^FDOWN .B ^FDOWN .TQ +.SCITECO_TOPIC ^FUP .B ^FUP Inserted when the down/up cursor keys are pressed. .TP +.SCITECO_TOPIC ^FLEFT .B ^FLEFT .TQ +.SCITECO_TOPIC ^FSLEFT .B ^FSLEFT Inserted when the left or shift-left cursor keys are pressed. .TP +.SCITECO_TOPIC ^FRIGHT .B ^FRIGHT .TQ +.SCITECO_TOPIC ^FSRIGHT .B ^FSRIGHT Inserted when the right or shift-right cursor keys are pressed. .TP +.SCITECO_TOPIC ^FHOME .B ^FHOME .TQ +.SCITECO_TOPIC ^FSHOME .B ^FSHOME Inserted when the Home or shift-Home keys are pressed. .TP +.SCITECO_TOPIC ^FF .BI ^FF x Inserted when the Fx-key is pressed .RI ( x is a number between 0 and 63). .TP +.SCITECO_TOPIC ^FDC .B ^FDC .TQ +.SCITECO_TOPIC ^FSDC .B ^FSDC Inserted when the Delete or shift-Delete key is pressed. .TP +.SCITECO_TOPIC ^FIC .B ^FIC .TQ +.SCITECO_TOPIC ^FSIC .B ^FSIC Inserted when the Insert or shift-Insert key is pressed. .TP +.SCITECO_TOPIC ^FPPAGE .B ^FPPAGE .TQ +.SCITECO_TOPIC ^FNPAGE .B ^FNPAGE Inserted when the Page-Up or Page-Down key is pressed. .TP +.SCITECO_TOPIC ^FPRINT .B ^FPRINT .TQ +.SCITECO_TOPIC ^FSPRINT .B ^FSPRINT Inserted when the Print or shift-Print key is pressed. .TP +.SCITECO_TOPIC ^FA1 .B ^FA1 .TQ +.SCITECO_TOPIC ^FA3 .B ^FA3 .TQ +.SCITECO_TOPIC ^FB2 .B ^FB2 .TQ +.SCITECO_TOPIC ^FC1 .B ^FC1 .TQ +.SCITECO_TOPIC ^FC3 .B ^FC3 Inserted when the numeric key pad's upper left key (7), upper right key (9), central key (5), lower left key (1), @@ -211,17 +241,23 @@ or lower right key (3) is pressed and num-lock is disabled. The key-pad's cursor keys are handled like the regular cursor keys. .TP +.SCITECO_TOPIC ^FEND .B ^FEND .TQ +.SCITECO_TOPIC ^FSEND .B ^FSEND Inserted when the End or shift-End key is pressed. .TP +.SCITECO_TOPIC ^FHELP .B ^FHELP .TQ +.SCITECO_TOPIC ^FSHELP .B ^FSHELP Inserted when the Help or shift-Help key is pressed. .TQ +.SCITECO_TOPIC ^FCLOSE .B ^FCLOSE +ISCITECO_TOPIC when the Close key has been pressed. Inserted when the Close key has been pressed. More importantly, this key is emulated in some GUIs (notably GTK+) when the user tries to close \*(ST's @@ -274,7 +310,9 @@ states. For instance, to enable the \(lq^FRIGHT\(rq function key macro only in the \(lqstart\(rq state, you could set: .EX +.SCITECO_TT 1^_U[^FRIGHT] +.SCITECO_TT_END .EE .LP A set of useful Function Key Macros are provided in the @@ -298,6 +336,7 @@ are self-inserting, i.e. they insert themself into the command stream and may be processed as regular commands or part of them. . .SS Immediate Editing Commands +.SCITECO_TOPIC immediate . In the following table, the Immediate Editing Commands are outlined. Some of them are ubiquitous and are not used used as regular @@ -311,12 +350,14 @@ TECO implementations. Most of these commands are control codes, so their control code mnemonics are given as well. . +.SCITECO_TT 90n .TS expand,allbox,tab(;); LB LB LB LB LBX L L L L L. Name;Code;Mnemonics;Context;Description T{ +.SCITECO_TOPIC ^G toggle Toggle modifier T};7;^G;T{ Everywhere @@ -330,6 +371,7 @@ effectively switches between undo and redo modes. The modifier also influences the behaviour of the TAB key. T} T{ +.SCITECO_TOPIC ^J enter LF CR Insert end of line sequence T};10;^J, Return, Enter;T{ Everywhere @@ -340,12 +382,14 @@ If automatic end of line sequence translation is disabled, the return key will insert the current buffer's end of line sequence (line feed; carriage return, line feed; or carriage return) according to the +.SCITECO_TOPIC SCI_GETEOLMODE .B SCI_GETEOLMODE Scintilla message. In auto-EOL-translation mode, the return key will always insert a line feed. T} T{ +.SCITECO_TOPIC ^H backspace Rub out character T};8;^H, Backspace;T{ Everywhere @@ -365,6 +409,7 @@ Inserts the next character from the rubbed out part of the command line. T} T{ +.SCITECO_TOPIC ^W Rub out word/command T};23;^W;T{ Non-empty file name arguments @@ -382,6 +427,7 @@ Non-empty string arguments T};T{ Rub out last word according to Scintilla's definition of a word as set by +.SCITECO_TOPIC SCI_SETWORDCHARS .BR SCI_SETWORDCHARS . T} \^;\^;\^;T{ @@ -421,6 +467,7 @@ i.e. insert at least one character and repeat until a new command could begin. T} T{ +.SCITECO_TOPIC ^U Rub out string T};21;^U;T{ String arguments @@ -491,11 +538,13 @@ This takes Scintilla's indention policy into account and results in the same indention as the \fB^I\fP command. T} T{ +.SCITECO_TOPIC ^Z suspend Suspend process T};26;^Z;T{ Everywhere T};T{ Suspends process using +.SCITECO_TOPIC SIGTSTP .BR SIGTSTP . This is only an immediate editing command on platforms supporting this signal (usually Unices). @@ -507,6 +556,7 @@ work as an immediate editing command in the GUI or as a signal dispatched from an associated console or from another process. T} T{ +.SCITECO_TOPIC interrupt Interrupt T};3;^C;T{ \*(ST is busy @@ -527,6 +577,7 @@ is self-inserting and might be typed as part of regular commands. The \fB^C\fP command itself is disallowed in interactive mode, though. T} .TE +.SCITECO_TT_END SP . .SS Undo and Redo . @@ -535,6 +586,7 @@ effectively constitute \*(ST's undo and redo support. As all features implemented by the immediate editing commands, undo and redo is only possible when using \*(ST interactively. .LP +.SCITECO_TOPIC rubout undo When a character is rubbed out, \*(ST reverses the side effects it had when it was typed. The rubbed out characters are not discarded immediately but kept @@ -548,6 +600,7 @@ they can still be seen in the command line's rubbed out area. The rubbed out command line is not a part of the command-line macro, though. .LP +.SCITECO_TOPIC rubin redo Changes can be redone by typing the characters at the command line cursor or using one of the re-insertion commands \(em therefore undo and redo looks like moving the command line cursor back and forth. @@ -585,6 +638,7 @@ Global and local Q-Registers are not affected by command line termination. . .SS Auto Completion . +.SCITECO_TOPIC autocomplete The immediate editing commands that perform auto-completions, do so in a manner similar to Posix shells. Upon first invocation they try to fully or partially complete the file @@ -626,6 +680,7 @@ in the user's home directory. . . .SH USER INTERFACE +.SCITECO_TOPIC UI "user interface" . \*(ST can be built with support for different textual and graphical user interfaces. @@ -638,6 +693,7 @@ user-interface agnostic macros and profiles easier. The user interface will always be segmented into the following areas from top of the program window to bottom: .IP \(bu 2 +.SCITECO_TOPIC info The \fIinfo area\fP identifying the currently edited buffer or Q-Register. This area is currently sometimes omitted. @@ -655,6 +711,7 @@ that occurred. This area will show errors, warnings, \(lquser messages\(rq and other notes and tries to highlight them appropriately. .IP \(bu +.SCITECO_TOPIC popup The auto-completion \fIpopup area\fP which is only shown when presenting the user with a choice of auto-completions. This area will overlap the \fIScintilla\fP and \fImessage @@ -666,6 +723,7 @@ This is currently a single line of text that is scrolled automatically. . .SS Colors and Theming +.SCITECO_TOPIC colors theming . \*(ST supports customizing its look predominantly by setting up the current Scintilla view using Scintilla messages @@ -674,6 +732,7 @@ Most visual properties of the Scintilla view can be set via its styles. This is also how syntax highlighting (lexing) is set up. .LP +.SCITECO_TOPIC STYLE_DEFAULT The \fBSTYLE_DEFAULT\fP (32) style defines the default foreground, background color, font etc. and is initialized to white on black with some monospaced font by \*(ST. @@ -690,6 +749,7 @@ The command line area on the other hand will be styled with the original colors of \fBSTYLE_DEFAULT\fP and should look similar to the current Scintilla view. .LP +.SCITECO_TOPIC STYLE_CALLTIP The \fBSTYLE_CALLTIP\fP (38) style is also accessed by \*(ST to style the \fIpopup area\fP and is initialized to black on (light) blue by \*(ST. @@ -704,6 +764,7 @@ macro or \fBED\fP hook (for syntax highlighting). and lexer configurations for a wide range of languages. . .SS Gtk CSS Styling +.SCITECO_TOPIC CSS . While the tools mentioned above are sufficient for Curses UIs, the Gtk+ 3 UI has many more styling possibilities. @@ -717,15 +778,19 @@ Therefore \*(ST automatically exports the following Gtk CSS variables that can be referred to by user-provided CSS files: .TP +.SCITECO_TOPIC @sciteco_default_fg_color .B @sciteco_default_fg_color The foreground color of Scintilla's \fBSTYLE_DEFAULT\fP. .TP +.SCITECO_TOPIC @sciteco_default_bg_color .B @sciteco_default_bg_color The background color of Scintilla's \fBSTYLE_DEFAULT\fP. .TP +.SCITECO_TOPIC @sciteco_calltip_fg_color .B @sciteco_calltip_fg_color The foreground color of Scintilla's \fBSTYLE_CALLTIP\fP. .TP +.SCITECO_TOPIC @sciteco_calltip_bg_color .B @sciteco_calltip_bg_color The background color of Scintilla's \fBSTYLE_CALLTIP\fP. .LP @@ -748,6 +813,7 @@ CSS theming. . . .SH ARITHMETICS AND EXPRESSIONS +.SCITECO_TOPIC arithmetics expressions . \*(ST abstracts classic TECO's scheme of commands accepting at most two prefix arguments and returning at most one value for the next command @@ -784,52 +850,66 @@ binary (bit by bit) negation for instance using the command. . .SS Operators +.SCITECO_TOPIC operators . The following binary operators are supported with descending precedence, whereas borders separate operators of the \fIsame\fP precedence: +.SCITECO_TT 90n .TS expand,box,tab(;); L LX. \fIbase\fB ^* \fIpower\fR;T{ +.SCITECO_TOPIC ^* power Raise \fIbase\fP to \fIpower\fP. T} = \fIa\fB ^/ \fIb\fR;T{ +.SCITECO_TOPIC ^/ remainder modulo Remainder of \fIa\fP divided by \fIb\fP. It is actually a modulo operation conforming to the host C compiler's modulo semantics. T} \fIa\fB / \fIb\fR;T{ +.SCITECO_TOPIC / divide slash Divide \fIa\fP by \fIb\fP. Naturally it is a division without remainder. T} \fIa\fB * \fIb\fP;T{ +.SCITECO_TOPIC * multiply asterisk Multiply \fIa\fP by \fIb\fP. T} = \fIa\fB - \fIb\fP;T{ +.SCITECO_TOPIC - subtract minus Subtract \fIb\fP from \fIa\fP. T} \fIa\fB + \fIb\fP;T{ +.SCITECO_TOPIC + add plus Add \fIb\fP to \fIa\fP. T} = \fIa\fB & \fIb\fP;T{ +.SCITECO_TOPIC & and ampersand Binary AND. T} = \fIa\fB ^# \fIb\fP;T{ +.SCITECO_TOPIC ^# xor Binary exclusive OR (XOR). T} = \fIa\fB # \fIb\fP;T{ +.SCITECO_TOPIC # or hash Binary OR. T} .TE +.SCITECO_TT_END SP .LP +.SCITECO_TOPIC associativity All binary operators are \fIleft-associative\fP, ie. associate from left to right, in \*(ST. +.SCITECO_TOPIC ( ) brackets Round brackets may be used for grouping expressions to override operator precedence and associativity. For instance, since \(lq\fB^/\fP\(rq, \(lq\fB/\fP\(rq and \(lq\fB*\fP\(rq @@ -851,6 +931,7 @@ dealing with braces. As the current behaviour has probably little benefits, the rules governing braces might be made stricter in a future release of \*(ST. .LP +.SCITECO_TOPIC , comma barrier Another construct that may be used as an argument barrier to explicitly separate arguments is the comma (\(lq,\(rq). It is obligatory when trying to push a sequence of number constants @@ -867,6 +948,7 @@ commands are used). The only unary operator currently supported is .RB \(lq - \(rq. The minus-operator is special and has unique semantics. +.SCITECO_TOPIC prefix It sets the so called \fBprefix sign\fP which is 1 by default to -1. This prefix sign may be evaluated by commands \(em most often it is the @@ -881,6 +963,7 @@ numbers the result is a negative number. . . .SH BUFFER RING +.SCITECO_TOPIC ring . \*(ST organizes files to edit in the so called buffer ring. The ring is a circular list of buffers. @@ -930,6 +1013,7 @@ or inserting characters by code, the code may be an Unicode codepoint instead of byte-sized integer. Currently however, \*(ST will only handle ASCII files. .LP +.SCITECO_TOPIC "EOL translation" To simplify working with files using different end of line sequences (combinations of carriage return and line feed), \*(ST implements an \fIautomatic EOL translation\fP @@ -959,7 +1043,9 @@ The feature is enabled by default but is controlled by bit 4 of the \fBED\fP flag setting. It can be turned off by executing: .EX +.SCITECO_TT 16,0ED +.SCITECO_TT_END .EE This may be beneficial when working with very large files \(em as the EOL translation imposes a performance penalty \(em @@ -972,6 +1058,7 @@ For more details, please refer to this manual's command reference. . .SS Buffer Editing Hooks +.SCITECO_TOPIC hooks . When opening or editing a file with the \fBEB\fP command or when closing a file with the \fBEF\fP command, you @@ -983,7 +1070,9 @@ editing operations. Hooks are by default disabled. To enable them, set bit 5 in the \fBED\fP flags: .EX +.SCITECO_TT 0,32ED +.SCITECO_TT_END .EE \*(ST will now execute the macro in global Q-Register \(lqED\(rq whenever a relevant operation is performed. @@ -1068,6 +1157,7 @@ hooks (see . . .SH COMMAND SYNTAX +.SCITECO_TOPIC syntax . \*(ST's command syntax is quite flexible and diverse but may be categorized into some base command types. @@ -1108,27 +1198,34 @@ has been completely specified and updates to the string arguments are handled interactively. . .SS Modifiers +.SCITECO_TOPIC modifiers . A command's behaviour or syntax may be influenced by so called modifiers written in front of commands. When specifying more than one modifier their order is insignificant. .LP +.SCITECO_TOPIC : colon The colon (\fB:\fP) modifier usually prevents a command from failing and instructs it to return a condition (success/failure) boolean instead. .EX +.SCITECO_TT 1000:C= +.SCITECO_TT_END .EE For instance if \(lq1000C\(rq would fail, \(lq1000:C\(rq will return 0 instead. .LP +.SCITECO_TOPIC @ at The at (\fB@\fP) modifier allows the string termination character to be changed for individual commands. The alternative termination character must be specified just before the first string argument. For instance: .EX +.SCITECO_TT @FS/foo/bar/ +.SCITECO_TT_END .EE Any character may be used as an alternative termination character. There is one special case, though. @@ -1140,12 +1237,15 @@ be chosen. This feature is especially useful for embedding TECO code in string arguments, as in: .EX +.SCITECO_TT @^Um{ @FS{foo}/bar/ } +.SCITECO_TT_END .EE . .SH Q-REGISTERS +.SCITECO_TOPIC Q-Register . \*(ST may store data in so called Q-Registers. Each Q-Register cell has an integer and string part (can store @@ -1187,6 +1287,7 @@ Some of the registers with special significance are initialized by \*(ST while others must be manually defined. The following list is an overview of all special global registers: .TP 2 +.SCITECO_TOPIC "search condition" .BR _ " (underscore)" Search string and search condition register. Also used by the globbing command \fBEN\fP, so it is also @@ -1198,6 +1299,7 @@ Replacement string register. Its integer part is currently unused. It is initialized automatically on startup. .TP +.SCITECO_TOPIC filename .BR * " (asterisk)" File name (string part) and id (numeric part) of current buffer in ring. @@ -1221,10 +1323,13 @@ buffer with \(lq-%*\fB$\fP\(rq, changing to the next buffer with \(lq%*\fB$\fP\(rq and changing the current buffer temporarily: .EX +.SCITECO_TT [* ! ...change current buffer... ! ]* +.SCITECO_TT_END .EE The register is initialized automatically on startup. .TP +.SCITECO_TOPIC "working directory" .BR $ " (dollar)" The process' current working directory (string part). Its numeric part is currently unused. @@ -1237,7 +1342,9 @@ directory in a manner similar to the \fBFG\fP command. This allows you to change the current directory temporarily with the following idiom: .EX +.SCITECO_TT [$ ! ...change current directory... ! ]$ +.SCITECO_TT_END .EE As with \fBFG\fP, relative directories may be specified but querying \(lq$\(rq will still return an absolute path. @@ -1267,6 +1374,7 @@ Their numeric parts are currently unused. The mechanisms involved are documented more elaborately in .BR sciteco (1). .TP +.SCITECO_TOPIC ~ clipboard .BI ~ clipboard These registers constitute \*(ST's support for system clipboards. Clipboard support is highly UI-specific, so different @@ -1277,6 +1385,7 @@ every available clipboard either on startup or only when entering interactive mode. The register \(lq~\(rq refers to the default clipboard which will always exist if clipboards are supported. +.SCITECO_TOPIC ~P ~S ~C Other commonly used clipboard registers are \(lq~P\(rq for the primary selection, \(lq~S\(rq for the secondary selection and \(lq~C\(rq for the clipboard selection. @@ -1284,6 +1393,7 @@ The existence of a clipboard register can thus be checked in macros to determine whether getting and modifying that particular clipboard is supported natively. .br +.SCITECO_TOPIC xterm \*(ST does \fBnot\fP generally support clipboards on ncurses, but has special support when used with a sufficiently recent version of \fBxterm\fP(1). @@ -1293,6 +1403,7 @@ automatically, users will have to set the flag 256 of the the \fISetSelection\fP and \fIGetSelection\fP window operations. \*(ST will still check whether XTerm is actually used in a particular session. +.SCITECO_TOPIC xclip If native clipboard support is unavailable, users may still fall back to using external tools like \fBxclip\fP(1) with the \fBEC\fP command. @@ -1373,6 +1484,7 @@ For instance the specifications \(lqa\(rq and \(lqA\(rq are equivalent to \(lq[A]\(rq. . .SS Push-Down List +.SCITECO_TOPIC "push down" stack . Another data structure supported by \*(ST is the Q-Register push-down list. @@ -1387,11 +1499,14 @@ commands. For instance to search in a macro without overwriting the contents of the search register you could write: .EX +.SCITECO_TT [_ Sfoo$ ]_ +.SCITECO_TT_END .EE . . .SH STRING-BUILDING CHARACTERS +.SCITECO_TOPIC "string building" . As alluded to earlier \*(ST supports special characters in command string arguments and long Q-Register names. @@ -1426,6 +1541,7 @@ character and their case is insignificant. In the following list of supported expressions, the caret-notation thus refers to the corresponding control code: .TP +.SCITECO_TOPIC ^Qc ^Rc quote .BI ^Q c .TQ .BI ^R c @@ -1433,6 +1549,7 @@ Escape character \fIc\fP. The character is not handled as a string building character, so for instance \(lq^Q^Q\(rq translates to \(lq^Q\(rq. .TP +.SCITECO_TOPIC ^V^V ^Vc lower .B ^V^V .TQ .BI ^V c @@ -1440,11 +1557,13 @@ Translates all following characters into lower case. When \fB^V\fP is not followed by \fB^V\fP, a single character \fIc\fP is lower-cased. .TP +.SCITECO_TOPIC ^W^W ^Wc .B ^W^W .TQ .BI ^W c Analogous to \fB^V\fP, but upper-cases characters. .TP +.SCITECO_TOPIC ^E\\ ^E\\q .BI ^E\(rs q Expands to the formatted number stored in the numeric part of Q-Register \fIq\fP. @@ -1455,16 +1574,19 @@ Currently, long Q-Register names have a separate independant level of string building character processing, allowing you to build Q-Register names whose content is then expanded. .TP +.SCITECO_TOPIC ^EU ^EUq .BI ^EU q Expands to the character whose code is stored in the numeric part of Q-Register \fIq\fP. For instance if register \(lqA\(rq contains the code 66, \(lq^EUa\(rq expands to the character \(lqB\(rq. .TP +.SCITECO_TOPIC ^EQ ^EQq .BI ^EQ q Expands to the string contents of the Q-Register specified by \fIq\fP. .TP +.SCITECO_TOPIC ^E@ ^E@q .BI ^E@ q Expands to the shell-quoted string contents of the Q-Register specified by \fIq\fP. @@ -1475,6 +1597,7 @@ This is useful when generating UNIX shell code or when passing registers with unknown contents as parameters to external commands using the \fBEC\fP command. .TP +.SCITECO_TOPIC ^EN ^ENq .BI ^EN q Expands to the string contents of the Q-Register specified by \fIq\fP but with glob pattern wildcards escaped. @@ -1491,6 +1614,7 @@ be escaped. . . .SH PATTERN MATCH CHARACTERS +.SCITECO_TOPIC pattern . \*(ST's search and replace commands allow the use of wildcards for pattern matching. @@ -1506,38 +1630,47 @@ The following pattern match constructs are supported for matching one character in different character classes (caret-notations refer to the corresponding control characters): .TP +.SCITECO_TOPIC ^S ^EB .B ^S .TQ .B ^EB Matches all non-alpha-numeric characters. .TP +.SCITECO_TOPIC ^EA .B ^EA Matches all alphabetic characters. .TP +.SCITECO_TOPIC ^EC .B ^EC Matches all symbol constituents. These are currently defined as alpha-numeric characters, dot (.) and dollar ($) signs. .TP +.SCITECO_TOPIC ^ED .B ^ED Matches all digits. .TP +.SCITECO_TOPIC ^EG ^EGq .BI ^EG q Matches all characters in the string of the Q-Register specified by \fIq\fP, i.e. one of the characters in the register. .TP +.SCITECO_TOPIC ^EL .B ^EL Matches all line break characters. These are defined as carriage return, line-feed, vertial tab and form feed. .TP +.SCITECO_TOPIC ^ER .B ^ER Matches all alpha-numeric characters. .TP +.SCITECO_TOPIC ^EV .B ^EV Matches all lower-case alphabetic characters. .TP +.SCITECO_TOPIC ^EW .B ^EW Matches all upper-case alphabetic characters. .TP @@ -1548,24 +1681,29 @@ contains only the character itself. The following additional pattern match constructs are supported (caret-notations refer to the corresponding control characters): .TP +.SCITECO_TOPIC ^X ^EX .B ^X .TQ .B ^EX Matches any character. .TP +.SCITECO_TOPIC ^N .BI ^N class Matches any character \fBnot\fP in \fIclass\fP. All constructs listed above for matching classes may be used. .TP +.SCITECO_TOPIC ^EM .BI ^EM pattern Matches many occurrences (at least one) of \fIpattern\fP. Any pattern match construct and non-magic character may be used. .TP +.SCITECO_TOPIC ^ES .B ^ES Matches any sequence of whitespace characters (at least one). Whitespace characters are defined as line-break characters, the space and horizontal tab characters. .TP +.SCITECO_TOPIC ^E[ .BI ^E[ pattern1 , pattern2 , ... ] Matches one in a list of patterns. Any pattern match construct may be used. @@ -1639,6 +1777,7 @@ These are documented in the section .BR "COMMANDLINE EDITING" . . .SS Glob Patterns +.SCITECO_TOPIC glob . Some commands accept glob patterns in their file name arguments to perform pattern matching @@ -1685,6 +1824,7 @@ wildcards. . . .SH FLOW CONTROL +.SCITECO_TOPIC flow . \*(ST is a structured imperative language. Commands are executed from left to right. @@ -1718,6 +1858,7 @@ the program counter and influencing parsing, it is described in this document's command reference. \*(ST may do simple unconditional and computed gotos. .LP +.SCITECO_TOPIC label Labels are symbolic and are defined with the following syntax: .br .BI ! label ! @@ -1731,10 +1872,12 @@ Therefore every macro invocation has its own label namespace and gotos to a label have constant complexity once a label has been parsed. Terminating a macro execution (or command line) fails if a label that is jumped to has not been defined. +.SCITECO_TOPIC comment Labels also have another important role in \*(ST \(em they are used as comments. . .SS Loops +.SCITECO_TOPIC < > loop . Gotos may be used for looping, but \*(ST also supports a dedicated structured looping construct. @@ -1774,16 +1917,20 @@ infinite one. Additionally \*(ST supports special colon-modified forms of the loop start and end commands for processing the argument stack dynamically. +.SCITECO_TOPIC :> The \fB:>\fP loop end command will \fInot\fP pop values left on the stack since the beginning of the loop and can be used to aggregate stack values. For instance, the following command will leave the numbers 1 to 5 on the expression stack: .EX +.SCITECO_TT 0Ua 5<%a:> +.SCITECO_TT_END .EE The command can be understood as an aggregated form of the expression \(lq(%a,%a,%a,%a,%a)\(rq. +.SCITECO_TOPIC :< Consequently, the colon-modified loop start command will \fInot\fP represent an argument barrier and the corresponding loop end command will not discard any values which is useful @@ -1791,7 +1938,9 @@ for looping over the contents of the stack. E.g. the following command will print the numbers 1 to 5 (actually every additional number argument): .EX +.SCITECO_TT 1,2,3,4,5,-1:<"~1;'=> +.SCITECO_TT_END .EE If the loop start is colon-modified, the colon in front of the loop end command is ignored if present. @@ -1801,6 +1950,9 @@ may be used in loops like \fBF<\fP and \fBF>\fP. They are described in the reference section of this manual. . .SS Conditionals +.\" NOTE: Two quoted double-quotes are necessary to escape +.\" a single double quote in macro arguments +.SCITECO_TOPIC """" conditional if then else . Last but not least, \*(ST supports so called conditionals. They correspond to structured IF-THEN-ELSE statements @@ -1826,6 +1978,7 @@ The possible conditions are defined in the following list. Unless \fIn\fP is defined optional, the conditionals described below yield an error if \fIn\fP is omitted: .TP +.SCITECO_TOPIC """~" \# [n]"~ [\fIn\fP]\fB\(dq~\fP Applies if \fIn\fP is \fBnot\fP given (i.e. the argument @@ -1837,23 +1990,29 @@ parameter values. For instance the following macro inserts \fIn\fP tab characters (one by default): .EX +.SCITECO_TT @^Ut{ "~1'<9@I//> } +.SCITECO_TT_END .EE .TP +.SCITECO_TOPIC """A" .IB n \(dqA Applies if \fIn\fP is the code of an alphabetic character. .TP +.SCITECO_TOPIC """C" .IB n \(dqC Applies if \fIn\fP is the code of a symbol constituent. Like in pattern matching, a symbol constituent is defined as an alpha-numeric character, dot, dollar or underscore. .TP +.SCITECO_TOPIC """D" .IB n \(dqD Applies if \fIn\fP is the code of a digit character (0 to 9). The current radix is insignificant. .TP +.SCITECO_TOPIC """I" .IB n \(dqI Applies if \fIn\fP is the code of a directory separator (e.g. \(lq/\(rq on UNIX, \(lq\\\(rq or \(lq/\(rq on Windows). @@ -1865,6 +2024,7 @@ in portable macros. This is not the case, for instance when working with environment registers. .TP +.SCITECO_TOPIC """S" """T" .IB n \(dqS .TQ .IB n \(dqT @@ -1873,6 +2033,7 @@ success (or truth). Therefore it is equivalent to a check for less than zero (negative). .TP +.SCITECO_TOPIC """F" """U" .IB n \(dqF .TQ .IB n \(dqU @@ -1881,6 +2042,7 @@ failure (or falsehood). Therefore it is equivalent to a check for greater than or equal to zero (non-negative). .TP +.SCITECO_TOPIC """E" """=" .IB n \(dqE .TQ .IB n \(dq= @@ -1890,6 +2052,7 @@ To check two values \fIa\fP and \fIb\fP for equality you will commonly write: .IB a - b \(dq= .TP +.SCITECO_TOPIC """G" """>" .IB n \(dqG .TQ .IB n \(dq> @@ -1899,6 +2062,7 @@ To check if a value \fIa\fP is greater than a value \fIb\fP you will commonly write: .IB a - b \(dq> .TP +.SCITECO_TOPIC """L" """<" .IB n \(dqL .TQ .IB n \(dq< @@ -1908,6 +2072,7 @@ To check if a value \fIa\fP is less than a value \fIb\fP you will commonly write: .IB a - b \(dq< .TP +.SCITECO_TOPIC """N" .IB n \(dqN Applies if \fIn\fP is not zero. .br @@ -1915,13 +2080,16 @@ To check two values \fIa\fP and \fIb\fP for inequality you will commonly write: .IB a - b \(dqN .TP +.SCITECO_TOPIC """R" .IB n \(dqR Applies if \fIn\fP is the code of an alpha-numeric character. .TP +.SCITECO_TOPIC """V" .IB n \(dqV Applies if \fIn\fP is the code of a lower-case alphabetic character. .TP +.SCITECO_TOPIC """W" .IB n \(dqW Applies if \fIn\fP is the code of a upper-case alphabetic character. @@ -1934,6 +2102,7 @@ loops in conditional blocks. . . .SH COMMAND REFERENCE +.SCITECO_TOPIC reference . This section documents all of the commands supported by \*(ST. diff --git a/doc/sciteco.tmac b/doc/sciteco.tmac new file mode 100644 index 0000000..7613c6e --- /dev/null +++ b/doc/sciteco.tmac @@ -0,0 +1,65 @@ +.\" sciteco.tmac +.\" +.\" grosciteco is similar to grotty, so we can +.\" inherit its definitions: +.nroff +.do mso tty.tmac +. +.\" +.\" Define topics at the current document position. +.\" This is handled by grosciteco to create a topic index +.\" at the top of the file which is in turn read by SciTECO +.\" to build a global help topic index. +.\" +.\" NOTE: We let Troff handle the argument processing, since +.\" parsing them in SciTECO would be tricky. +.\" +.de SCITECO_TOPIC +. while \\n(.$ \{\ +. device sciteco_topic:\\$1 +. shift 1 +. \} +.. +. +. +.\" +.\" grosciteco does not handle font families right now +.\" and probably will never do because of the limited +.\" number of Scintilla styles available. +.\" But even if we did, we sometimes have to enforce +.\" a fixed-width font for drawings and tables, since +.\" they can only be "typeset" with glyphs by Scintilla. +.\" +.de SCITECO_TT +. if \\n(.$ .ll \\$* +. device sciteco_tt +.. +. +.de SCITECO_TT_END +. if '\\$1'SP' .sp +. device sciteco_tt_end +. ll 65535n +.. +. +.\" +.\" Effectively disable paragraph filling in man pages. +.\" Word wrapping will be performed by Scintilla. +.\" +.ll 65535n +.nr LT 90n +. +.\" +.\" remove hyphenation +.\" +.nh +.nr HY 0 +. +.de hy +.. +.de nh +.. +. +.\" avoid line breaks after hyphen-like characters. +.cflags 0 -\[hy]\[em]\[en] +. +.\" end of file, make sure this is the last line
\ No newline at end of file diff --git a/lib/Makefile.am b/lib/Makefile.am index 53a9be8..a66aaef 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -11,9 +11,12 @@ colorschemedir = $(scitecolibdir)/colors dist_colorscheme_DATA = colors/terminal.tes \ colors/solarized.tes +lexerdir = $(scitecolibdir)/lexers + +# Lexer configurations for language +# syntax highlighting. # This list must be extended when adding # a new lexer configuration: -lexerdir = $(scitecolibdir)/lexers dist_lexer_DATA = lexers/verilog.tes \ lexers/php.tes \ lexers/pascal.tes \ @@ -85,3 +88,8 @@ dist_lexer_DATA = lexers/verilog.tes \ lexers/rust.tes \ lexers/blitzbasic.tes \ lexers/caml.tes + +# This lexer is responsible for styling +# womanpages and is thus useful even when omitting +# the syntax highlighting lexers. +dist_lexer_DATA += lexers/woman.tes diff --git a/lib/lexers/woman.tes b/lib/lexers/woman.tes new file mode 100644 index 0000000..23c6905 --- /dev/null +++ b/lib/lexers/woman.tes @@ -0,0 +1,20 @@ +!* + * Womanpage Lexing: These are internal or third-party + * on-line documentation files used by SciTECO. + * In contrast to normal lexers, Womanpages are styled + * using a SciTECO macro that ships with the woman-page + * document (.woman.tec). + *! + +@[lexer.test.woman]{ + :EN*.womanQ* +} + +@[lexer.set.woman]{ + 1ESSETWRAPMODE + 1ESSETWRAPINDENTMODE + 10,1#4ESSETYCARETPOLICY + 32ESSTYLESETFONTTimes ESSTYLECLEARALL + + 1:EN*Q*.tec"S EMQ*.tec ' +} diff --git a/sample.teco_ini b/sample.teco_ini index 6360d14..9cc9e1c 100644 --- a/sample.teco_ini +++ b/sample.teco_ini @@ -18,9 +18,11 @@ EMQ[$SCITECOPATH]/session.tes M[lexer.auto] ! Set up margins ! - 33ESTEXTWIDTH9U.w - 5*Q.w,0ESSETMARGINWIDTHN - Q.w,2ESSETMARGINWIDTHN + [_:M[lexer.test.woman]]_"F + 33ESTEXTWIDTH9U.w + 5*Q.w,0ESSETMARGINWIDTHN + Q.w,2ESSETMARGINWIDTHN + ' 0,32ED ! fall through ! diff --git a/src/Makefile.am b/src/Makefile.am index 515accd..314faa4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -43,6 +43,7 @@ libsciteco_base_la_SOURCES = main.cpp sciteco.h \ spawn.cpp spawn.h \ glob.cpp glob.h \ goto.cpp goto.h \ + help.cpp help.h \ rbtree.cpp rbtree.h \ symbols.cpp symbols.h \ interface.cpp interface.h @@ -75,10 +76,10 @@ CLEANFILES = $(BUILT_SOURCES) \ symbols-scintilla.cpp : @SCINTILLA_PATH@/include/Scintilla.h \ symbols-extract.tes - $(BOOTSTRAP_SCITECO) -m @srcdir@/symbols-extract.tes \ - $< $@ "SCI_" scintilla + $(SCITECO_MINIMAL) -m @srcdir@/symbols-extract.tes \ + $< $@ "SCI_" scintilla symbols-scilexer.cpp : @SCINTILLA_PATH@/include/SciLexer.h \ symbols-extract.tes - $(BOOTSTRAP_SCITECO) -m @srcdir@/symbols-extract.tes \ - $< $@ "SCLEX_,SCE_" scilexer + $(SCITECO_MINIMAL) -m @srcdir@/symbols-extract.tes \ + $< $@ "SCLEX_,SCE_" scilexer diff --git a/src/help.cpp b/src/help.cpp new file mode 100644 index 0000000..9553f76 --- /dev/null +++ b/src/help.cpp @@ -0,0 +1,320 @@ +/* + * Copyright (C) 2012-2016 Robin Haberkorn + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> + +#include <glib.h> +#include <glib/gstdio.h> +#include <glib/gprintf.h> + +#include "sciteco.h" +#include "string-utils.h" +#include "parser.h" +#include "qregisters.h" +#include "ring.h" +#include "interface.h" +#include "help.h" + +namespace SciTECO { + +HelpIndex help_index; + +namespace States { + StateGetHelp gethelp; +} + +void +HelpIndex::load(void) +{ + gchar *lib_path; + gchar *women_path; + GDir *women_dir; + const gchar *basename; + + lib_path = QRegisters::globals["$SCITECOPATH"]->get_string(); + women_path = g_build_filename(lib_path, "women", NIL); + g_free(lib_path); + + women_dir = g_dir_open(women_path, 0, NULL); + if (!women_dir) { + g_free(women_path); + return; + } + + while ((basename = g_dir_read_name(women_dir))) { + gchar *filename, *filename_tec; + FILE *file; + gchar buffer[1024]; + gchar *topic; + + if (!g_str_has_suffix(basename, ".woman")) + continue; + + /* + * Open the corresponding SciTECO macro to read + * its first line. + */ + filename = g_build_filename(women_path, basename, NIL); + filename_tec = g_strconcat(filename, ".tec", NIL); + file = g_fopen(filename_tec, "r"); + g_free(filename_tec); + if (!file) { + /* + * There might simply be no support script for + * simple plain-text woman-pages. + * In this case we create a topic using the filename + * without an extension. + */ + topic = g_strndup(basename, strlen(basename)-6); + set(topic, filename); + g_free(topic); + g_free(filename); + continue; + } + + /* + * Each womanpage script begins with a special comment + * header containing the position to topic index. + * Every topic will be on its own line and they are unlikely + * to be very long, so we can use fgets() here. + * NOTE: Since we haven't opened with the "b" flag, + * fgets() will translate linebreaks to LF even on + * MSVCRT (Windows). + */ + if (!fgets(buffer, sizeof(buffer), file) || + !g_str_has_prefix(buffer, "!*")) { + interface.msg(InterfaceCurrent::MSG_WARNING, + "Missing or invalid topic line in womanpage script \"%s\"", + filename); + g_free(filename); + continue; + } + /* skip opening comment */ + topic = buffer+2; + + do { + gchar *endptr; + tecoInt pos = strtoul(topic, &endptr, 10); + gsize len; + + /* + * This also breaks at the last line of the + * header. + */ + if (*endptr != ':') + break; + + /* + * Strip the likely LF at the end of the line. + */ + len = strlen(endptr)-1; + if (G_LIKELY(endptr[len] == '\n')) + endptr[len] = '\0'; + + set(endptr+1, filename, pos); + } while ((topic = fgets(buffer, sizeof(buffer), file))); + + fclose(file); + g_free(filename); + } + + g_dir_close(women_dir); + g_free(women_path); +} + +HelpIndex::Topic * +HelpIndex::find(const gchar *name) +{ + Topic *ret; + + /* + * The topic index contains printable characters + * only (to avoid having to perform string building + * on the topic terms to be able to define control + * characters). + * Therefore, we expand control characters in the + * look-up string to their printable forms. + */ + gchar *term = String::canonicalize_ctl(name); + + Topic topic(term); + ret = (Topic *)RBTree::find(&topic); + g_free(term); + + return ret; +} + +void +HelpIndex::set(const gchar *name, const gchar *filename, tecoInt pos) +{ + Topic *topic = new Topic(name, filename, pos); + Topic *existing; + + existing = (Topic *)RBTree::find(topic); + if (existing) { + gchar *basename; + + if (!strcmp(existing->filename, filename)) { + /* + * A topic with the same name already exists + * in the same file. + * For the time being, we simply overwrite the + * last topic. + * FIXME: Perhaps make it unique again!? + */ + existing->pos = pos; + delete topic; + return; + } + + /* in another file -> make name unique */ + interface.msg(InterfaceCurrent::MSG_WARNING, + "Topic collision: \"%s\" defined in \"%s\" and \"%s\"", + name, existing->filename, filename); + + String::append(topic->name, ":"); + basename = g_path_get_basename(filename); + String::append(topic->name, basename); + g_free(basename); + } + + RBTree::insert(topic); +} + +/* + * Command states + */ + +/*$ + * ?[topic]$ -- Get help for topic + * + * Look up <topic> in the help index, opening + * the corresponding womanpage as a buffer and scrolling + * to the topic's position. + * The help index is built when this command is first + * executed, so the help system does not consume resources + * when not used (e.g. in a batch-mode script). + * + * \*(ST's help documents must be installed in the + * directory \fB$SCITECOPATH/women\fP, i.e. as part of + * the standard library. + * Each document consist of at least one plain-text file with + * the extension \(lq.woman\(rq. + * Optionally, a \*(ST script with the extension + * \(lq.woman.tec\(rq can be installed alongside the + * main document to define topics covered by this document + * and set up styling. + * + * The beginning of the script must be a header of the form: + * .EX + * !*\fIposition\fP:\fItopic1\fP + * \fIposition2\fP:\fItopic2\fP + * \fI...\fP + * *! + * .EE + * In other words it must be a \*(ST comment followed + * by an asterisk sign, followed by the first topic which + * is a buffer position, followed by a colon and the topic + * string. + * The topic string is terminated by the end of the line. + * The end of the header is marked by a single \(lq*!\(rq. + * Topic terms should be specified with printable characters + * only (e.g. use Caret+A instead of CTRL+A). + * When looking up a help term, control characters are + * canonicalized to their printable form, so the term + * \(lq^A\(rq is found both by Caret+A and CTRL+A. + * Also, while topic terms are not case folded, lookup + * is case insensitive. + * + * The rest of the script is not read by \*(ST internally + * but should contain styling for the main document. + * It is usually read by the standard library's lexer + * configuration system when showing a womanpage. + * If the \(lq.woman.tec\(rq macro is missing, + * \*(ST will define a single topic for the document based + * on the \(lq.woman\(rq file's name. + * + * The combination of plain-text document and script + * is called a \(lqwomanpage\(rq because these files + * are usually generated using \fBgroff\fP(1) with the + * \fIgrosciteco\fP formatter and the \fIsciteco.tmac\fP + * GNU troff macros. + * When using womanpages generated by \fIgrosciteco\fP, + * help topics can be defined using the \fBSCITECO_TOPIC\fP + * Troff macro. + * This flexible system allows \*(ST to access internal + * and third-party help files written in plain-text or + * with an arbitrary GNU troff macro package. + * As all GNU troff documents are processed at build-time, + * GNU troff is not required at runtime. + * + * The \fB?\fP command does not have string building enabled. + */ +void +StateGetHelp::initial(void) +{ + /* + * The help-index is populated on demand, + * so we start up quicker and batch mode does + * not depend on the availability of the standard + * library. + */ + if (G_UNLIKELY(!help_index.min())) + help_index.load(); +} + +State * +StateGetHelp::done(const gchar *str) +{ + HelpIndex::Topic *topic; + + BEGIN_EXEC(&States::start); + + topic = help_index.find(str); + if (!topic) + throw Error("Topic \"%s\" not found", str); + + ring.undo_edit(); + /* + * ED hooks with the default lexer framework + * will usually load the styling SciTECO script + * when editing the buffer for the first time. + */ + ring.edit(topic->filename); + + /* + * Make sure the topic is visible. + * We do need undo tokens for this (even though + * the buffer is removed on rubout if the woman + * page is viewed first) since we might browse + * multiple topics in the same buffer without + * closing it first. + */ + interface.undo_ssm(SCI_GOTOPOS, + interface.ssm(SCI_GETCURRENTPOS)); + interface.ssm(SCI_GOTOPOS, topic->pos); + + return &States::start; +} + +} /* namespace SciTECO */ diff --git a/src/help.h b/src/help.h new file mode 100644 index 0000000..db78979 --- /dev/null +++ b/src/help.h @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2012-2016 Robin Haberkorn + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __HELP_H +#define __HELP_H + +#include <string.h> + +#include <glib.h> +#include <glib/gprintf.h> + +#include "sciteco.h" +#include "parser.h" +#include "undo.h" +#include "rbtree.h" + +namespace SciTECO { + +class HelpIndex : public RBTree { +public: + class Topic : public RBTree::RBEntry { + public: + gchar *name; + gchar *filename; + tecoInt pos; + + Topic(const gchar *_name, const gchar *_filename = NULL, tecoInt _pos = 0) + : name(g_strdup(_name)), + filename(_filename ? g_strdup(_filename) : NULL), + pos(_pos) {} + ~Topic() + { + g_free(name); + g_free(filename); + } + + int + operator <(RBEntry &l2) + { + return g_ascii_strcasecmp(name, ((Topic &)l2).name); + } + }; + + void load(void); + + Topic *find(const gchar *name); + + void set(const gchar *name, const gchar *filename, + tecoInt pos = 0); +}; + +extern HelpIndex help_index; + +/* + * Command states + */ + +class StateGetHelp : public StateExpectString { +public: + StateGetHelp() : StateExpectString(false) {} + +private: + void initial(void); + State *done(const gchar *str); +}; + +namespace States { + extern StateGetHelp gethelp; +} + +} /* namespace SciTECO */ + +#endif diff --git a/src/parser.cpp b/src/parser.cpp index 97822e7..00ebaee 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -40,6 +40,7 @@ #include "search.h" #include "spawn.h" #include "glob.h" +#include "help.h" #include "cmdline.h" #include "ioview.h" #include "error.h" @@ -687,6 +688,7 @@ StateStart::StateStart() : State() transitions['"'] = &States::condcommand; transitions['E'] = &States::ecommand; transitions['I'] = &States::insert_building; + transitions['?'] = &States::gethelp; transitions['S'] = &States::search; transitions['N'] = &States::searchall; |