diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-08-06 16:46:37 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-08-06 16:46:37 +0300 |
commit | 280cb9da39fc7b5357f6071926d511394f6d0152 (patch) | |
tree | cdca852694fd3e4cc9293c374d16ac69d9be01ea /doc | |
parent | c5510d684e4879ab9a5295b4a1981888a4268627 (diff) | |
download | sciteco-280cb9da39fc7b5357f6071926d511394f6d0152.tar.gz |
command-line arguments are no longer passed via the unnamed buffer, but via special Q-registers ^Ax
* The unnamed buffer is also used for reading from --stdin, so you couldn't practically combine
--stdin with passing command-line arguments to macros.
* The old approach of passing command-line arguments via lines in the
unnamed buffer was flawed anyway as it wouldn't work with filenames containing LF.
This is just a very ancient feature, written when there weren't even long Q-reg names in SciTECO.
* You can now e.g. pipe into SciTECO and edit what was read interactively, e.g. `dmesg | sciteco -i`.
You can practically use SciTECO as a pager.
* htbl.tes is now a command-line filter (uses -qio).
* grosciteco.tes reads Troff intermediate code from stdin, so we no longer need
"*.intermediate" temporary files.
* added a getopt.tes test case to the testsuite.
* This change unfortunately breaks most macros accepting command-line arguments,
even if they used getopt.tes.
It also requires updating ~/.teco_ini - see fallback.teco_ini.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/Makefile.am | 28 | ||||
-rwxr-xr-x | doc/grosciteco.tes | 38 | ||||
-rw-r--r-- | doc/grosciteco.tes.1.in | 10 | ||||
-rw-r--r-- | doc/sciteco.1.in | 39 | ||||
-rw-r--r-- | doc/sciteco.7.template | 20 | ||||
-rwxr-xr-x | doc/tedoc.tes | 27 |
6 files changed, 89 insertions, 73 deletions
diff --git a/doc/Makefile.am b/doc/Makefile.am index 65f8556..f6e4dc1 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -40,40 +40,34 @@ install-exec-hook: womendir = $(scitecolibdir)/women women_DATA = grosciteco.tes.1.woman grosciteco.tes.1.woman.tec -CLEANFILES = grosciteco.tes.1 grosciteco.tes.1.intermediate +CLEANFILES = grosciteco.tes.1 EXTRA_DIST = grosciteco.tes.1.in women_DATA += tedoc.tes.1.woman tedoc.tes.1.woman.tec -CLEANFILES += tedoc.tes.1 tedoc.tes.1.intermediate +CLEANFILES += tedoc.tes.1 EXTRA_DIST += tedoc.tes.1.in women_DATA += sciteco.1.woman sciteco.1.woman.tec -CLEANFILES += sciteco.1 sciteco.1.intermediate +CLEANFILES += sciteco.1 EXTRA_DIST += sciteco.1.in women_DATA += sciteco.7.woman sciteco.7.woman.tec -CLEANFILES += sciteco.7 sciteco.7.intermediate sciteco.7.in +CLEANFILES += sciteco.7 sciteco.7.in EXTRA_DIST += sciteco.7.template women_DATA += tutorial.woman tutorial.woman.tec -CLEANFILES += tutorial.ms tutorial.intermediate +CLEANFILES += tutorial.ms EXTRA_DIST += tutorial.ms.in CLEANFILES += $(women_DATA) -# FIXME: *.intermediate files are only generated since SciTECO scripts -# cannot currently read stdin via --stdin while passing command-line -# arguments at the same time, so the grosciteco postprocessor -# has to be run on a separate file. -%.woman %.woman.tec : %.intermediate grosciteco.tes - $(SCITECO_FULL) -m -- @srcdir@/grosciteco.tes \ - $@ $< +%.woman %.woman.tec : % sciteco.tmac grosciteco.tes + @GROFF@ -wall -Z -Kutf-8 -Tutf8 -t -man -M@srcdir@ -msciteco $< | \ + $(SCITECO_FULL) -im -- @srcdir@/grosciteco.tes $@ -%.intermediate : % sciteco.tmac - @GROFF@ -wall -Z -Kutf-8 -Tutf8 -t -man -M@srcdir@ -msciteco $< >$@ - -tutorial.intermediate : tutorial.ms sciteco.tmac - @GROFF@ -wall -Z -Kutf-8 -Tutf8 -t -ms -M@srcdir@ -msciteco $< >$@ +tutorial.woman tutorial.woman.tec : tutorial.ms sciteco.tmac grosciteco.tes + @GROFF@ -wall -Z -Kutf-8 -Tutf8 -t -ms -M@srcdir@ -msciteco $< | \ + $(SCITECO_FULL) -im -- @srcdir@/grosciteco.tes $@ man_MANS = grosciteco.tes.1 tedoc.tes.1 sciteco.1 sciteco.7 diff --git a/doc/grosciteco.tes b/doc/grosciteco.tes index cbe0e61..a724a5f 100755 --- a/doc/grosciteco.tes +++ b/doc/grosciteco.tes @@ -1,16 +1,18 @@ -#!/usr/local/bin/sciteco -m -!* grosciteco.tes [-t <output-tec>] [--] <output-woman> <input> *! +#!/usr/local/bin/sciteco -mi +!* grosciteco.tes [-t <output-tec>] [--] <output> <input *! 0,2EJ !* FIXME: Memory limiting is too slow *! :EIQ[$SCITECOPATH]/getopt.tes !* Process command-line options *! -[optstring]t: M[getopt]"F (0/0) ' -LR 0X[output-woman] 2LR 0X[input] HK +[optstring]t: +M[getopt]U[output-woman] Q[output-woman]"< Invalid command-line^J 1 ' +EU[output-woman]Q[\[output-woman]] :Q[getopt.t]"< EU[getopt.t]Q[output-woman].tec ' -EBN[input] +EBN[output-woman] HK 1EB + 0EE !* Groff intermediate code is always ASCII *! !* skip whitespace characters *! @@ -54,7 +56,7 @@ EBN[input] !* FIXME: Works only for straight lines *! @[line]{ U.[to.v] U.[to.h] Q.[to.h]-Q[pos.h]"= Q.[to.v]-Q[pos.v]"= ' ' - [* EB + [* EBN[output-woman] 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 ' @@ -147,32 +149,32 @@ EBN[input] * a table). Only the line+column should no longer change. * Either store line+column or use markers. *! - [* EB 0:M[move] U.d ]* + [* EBN[output-woman] 0:M[move] U.d ]* :EU[topics]\.d: C :X[topics] L F< !cmd.xXsciteco_tt! - [* EB 0:M[move] U[ttstart] ]* + [* EBN[output-woman] 0:M[move] U[ttstart] ]* L F< !cmd.xXsciteco_tt_end! - [* EB 0:M[move] + [* EBN[output-woman] 0:M[move] -Q[ttstart]< Q[ttstart]ESSTARTSTYLING Q[ttstart]ESGETSTYLEAT+16,1ESSETSTYLING %[ttstart]> ]* L F< !cmd.xXsciteco_startstyling! - [* EB 0:M[move] U[stylestart] ]* + [* EBN[output-woman] 0:M[move] U[stylestart] ]* L F< !cmd.xXsciteco_setstyling! C :M#giU.s - [* EB 0:M[move] + [* EBN[output-woman] 0:M[move] Q[stylestart]ESSTARTSTYLING Q.s,(-Q[stylestart])ESSETSTYLING ]* L F< !cmd.xXsciteco_foldlevel! C :M#giU.[foldlevel] - [* EB 0:M[move] + [* EBN[output-woman] 0:M[move] Q.[foldlevel],(ESLINEFROMPOSITION)ESSETLINESTATE ]* L F< @@ -274,7 +276,7 @@ EBN[input] !cmd.t! :M#sw .(:M#sa).X.w - [* EB :Q.w:M[move] + [* EBN[output-woman] :Q.w:M[move] G.w :Q.w:M[style] ]* :Q.w%[pos.h] :M#sc F< @@ -285,17 +287,17 @@ EBN[input] | .(:M#sa).X.w 0Q[glyphs.Q.w]U.w ' - [* EB 1:M[move] + [* EBN[output-woman] 1:M[move] Q.wI 1:M[style] ]* :M#sc F< !cmd.c! :M#sw 0AU.w C - [* EB 1:M[move] + [* EBN[output-woman] 1:M[move] G[glyphs.U.w] 1:M[style] ]* :M#sc F< !cmd.N! :M#sw :M#giU.w - [* EB 1:M[move] + [* EBN[output-woman] 1:M[move] Q.wI 1:M[style] ]* :M#sc F< !cmd.n! @@ -336,7 +338,7 @@ Q*U* * TODO: The size can still be improved by using SCI_SETSTYLINGEX * if appropriate. *! -EB 0EE !* operate in single-byte mode *! +EBN[output-woman] 0EE !* operate in single-byte mode *! J 0U#cs 0U#cd < .ESGETSTYLEATUs Qs"< Qs= ' @@ -375,7 +377,7 @@ Q[cur.fl]"N !* * Save the clear-text part of the document into <output-woman> *! -2EL EWQ[output-woman] +2EL EW EQ[styles] diff --git a/doc/grosciteco.tes.1.in b/doc/grosciteco.tes.1.in index 9056a60..e720f3e 100644 --- a/doc/grosciteco.tes.1.in +++ b/doc/grosciteco.tes.1.in @@ -18,7 +18,7 @@ GNU roff post-processor for \*(ST .OP "-t" tec_output .OP "--" .I text_output -.I input +.RI < input .YS . . @@ -79,8 +79,8 @@ This is also the default when omitted. .IP "\fItext_output\fP The plain-text output file, e.g. \(lqgreat-macro.woman\(rq. .IP "\fIinput\fP" -The \fIinput\fP file is in \fBtroff\fP's device-independant -output format. +\fBtroff\fP's device-independant output format +is read from \fIstdin\fP. . . .SH SPECIAL TROFF MACROS @@ -168,8 +168,8 @@ a \*(ST macro package with a man page called .SCITECO_TT .EX groff -Z -Kutf-8 -Tutf8 -man -M@scitecodatadir@ -msciteco \\ - great-macro.tes.7sciteco >great-macro.tes.7sciteco.intermediate -grosciteco.tes great-macro.tes.7sciteco.woman great-macro.tes.7sciteco.intermediate + great-macro.tes.7sciteco | \\ +grosciteco.tes great-macro.tes.7sciteco.woman .SCITECO_TT_END .EE .RE diff --git a/doc/sciteco.1.in b/doc/sciteco.1.in index 0eec35f..c62723c 100644 --- a/doc/sciteco.1.in +++ b/doc/sciteco.1.in @@ -63,12 +63,13 @@ invoked as scripts by using a Hash-Bang line like .RS .SCITECO_TT .EX -#!@bindir@/sciteco -m +#!@bindir@/@PACKAGE@ -m .SCITECO_TT_END .EE .RE . .LP +.SCITECO_TOPIC argv arguments Note that UNIX Hash-Bang lines will only pass a \fBsingle\fP argument to the interpreter before the script's file name, so all required \*(ST options must be mangled into a single argument with their single-letter names. @@ -76,31 +77,29 @@ Passing option-like arguments (beginning with a dash) to scripts may cause problems because \*(ST might try to interpret these options. \*(ST thus stops parsing at the first non-option argument (which will always be the munged file name in a script invocation). -. -.LP -Upon startup \*(ST's buffer ring contains only one unnamed empty buffer. -First \*(ST reads from \fIstdin\fP into the unnamed buffer if \(lq--stdin\(rq -was given. -\# FIXME: This must change -.SCITECO_TOPIC argv arguments -Afterwards all command line arguments after the \*(ST options are passed as -.I arguments -to the munged macro by appending each argument on its own line to -the unnamed buffer. -The \fIscript\fP file name expected when \(lq--mung\(rq is given -is currently \fBnot\fP considered a macro argument. -In any case the current buffer position (called -.IR dot ) -is left at the beginning of the buffer. -The buffer is left \fIdirty\fP if anything was added to it. Optionally \(lq\-\-\(rq might be used to explicitly separate \*(ST options and macro arguments, but is never passed down as a macro argument. Since it's sometimes useful to pass down \(rq\-\-\(rq to the profile macro, you can use \(lq\-S\(rq, which is equivalent to \(lq\-\- \-\-\(rq. +All remaining arguments after the built-in processing of options +are passed to the executed macro using an array of global Q-registers \fB^A\fIx\fR. +The \fIscript\fP file name expected when \(lq\-\-mung\(rq is given +is currently \fBnot\fP included in this array. +Q-register \fB^A0\fP is the name of the current process as passed to C +programs in \(lqargv[0]\(rq. +. +.LP +Upon startup \*(ST's buffer ring always contains only one unnamed buffer. +If \(lq\-\-stdin\(rq is given, \*(ST first reads from \fIstdin\fP until end-of-file +into the unnamed buffer. +This is includes automatic EOL translation just like when using the \fBEB\fP command +and can therefore be disabled by specifying \(lq\-\-8bit\(rq. +If reading from \fIstdin\fP results in any text additions, the buffer is left \fIdirty\fP. +The current position (called dot) is always left at the beginning of the buffer. . .LP If the munged macro does not request program termination using the -\fBEX\fP command or exits using \fB^C\fP, \*(ST will automatically +\fBEX\fP command or exits using \fB^C^C\fP, \*(ST will automatically switch into its graphical \fIinteractive\fP mode. \*(ST may be built with different graphical user interfaces, including Curses and GTK+ based ones. @@ -546,6 +545,8 @@ dmesg | @PACKAGE@ -qioe '<%a\\@I/ / :L;>' .RE . .LP +This also works in interactive mode, so \(lq@PACKAGE@ -i\(rq +allows you to interactively edit text read from \fIstdin\fP. Suppose you would want to print only those lines from \fIstdin\fP matching \(lqiwm0:\(rq: .RS diff --git a/doc/sciteco.7.template b/doc/sciteco.7.template index bad7e7d..21385a3 100644 --- a/doc/sciteco.7.template +++ b/doc/sciteco.7.template @@ -1668,6 +1668,26 @@ the original clipboard contents, though. The numeric parts of the clipboard registers are currently not used by \*(ST. .TP +.SCITECO_TOPIC ^Ax +.BI ^A x +An argument passed on the operating system's command line. +\fIx\fP can be an integer beginning with 0. +.B ^A0 +is the name of the program, as passed via \(lqargv[0]\(rq to +C programs, and is guaranteed to always exist. +All remaining registers for \fIx\fP larger than or equal to 1 +represent the command-line parameters after all the built-in +options as reported by \(lq@PACKAGE@ --help\(rq. +In other words all the options processed by the \*(ST main program +including the file names after \(lq--mung\(rq are automatically +excluded from the +.BI ^A x +array. +The numeric parts of the argument registers are +currently not used by \*(ST. +For more details, see +.BR sciteco (1). +.TP .BI ^K key Key macro registers as documented in section .BR "KEY TRANSLATION" . diff --git a/doc/tedoc.tes b/doc/tedoc.tes index 885f41a..cc4f726 100755 --- a/doc/tedoc.tes +++ b/doc/tedoc.tes @@ -8,7 +8,7 @@ @[format_header]{ FD--S .,(:L"S.|Z')@Xa I^J - EBQ#tm + EBN[\#tm] I\# GENERATED FROM Q.#sc (\.#sc):^J I.SS Ga -A-10"N I^J ' :Q.[topics]"> @@ -45,7 +45,7 @@ J <FR^J^J^J;> J 0A-10"=D' ZJ -A-10"=-D' - EBQ#tm + EBN[\#tm] G.[header] I^J.^J } @@ -73,35 +73,34 @@ J <S<MC>; -D I^J -S< -D I^J.I > J <FRS^J^J;> J <FR^JS^J;> - EBN#tm + EBN[\#tm] G.c I^J.^J.^J } !* process command-line options *! -[optstring]C M[getopt]"F (0/0) ' +[optstring]C +M[getopt]U#ou Q#ou"< Invalid command-line^J 1 ' :Q[getopt.C]"< [comment.start]!* [comment.end]*! | [comment.start]/* [comment.end]*/ ' -LR 0X#ou -2LR 0X#tm EBN#tm EB L -[.f - <:L;R 0X.f EBQ.f EB L> -].f --EF +Q#ou+1U#tm Q#tmU.i <:Q[\.i]:; EBN[\.i] %.i> + +!* switch to the main troff template (#tm) *! +EB EF I\# -\# AUTOGENERATED FROM Q#tm +\# AUTOGENERATED FROM Q[\#tm] \# DO NOT EDIT MANUALLY!!! \#^J !* find insertion point *! -:FS^J.TEDOC^J^J"F(0/0)' +:FS^J.TEDOC^J^J"F Missing .TEDOC call^J 1 ' EJ-1< < - 2U* [*]#sc + 2U* [*].#sc !* extract comment *! SQ[comment.start]$; @@ -127,5 +126,5 @@ EJ-1< EF > -2EL EWQ#ou +2EL EWQ[\#ou] EX |