Document the listing module.

This commit is contained in:
Dominik Pantůček 2023-03-20 21:33:05 +01:00
parent f870430cf1
commit bb118c0fbe

View file

@ -80,6 +80,9 @@ Functional Modules
Support Modules
---------------
There modules are not specific to this project but had to be
implemented anyway to not require any external dependencies.
### ANSI
### Command Line parsing
@ -88,6 +91,43 @@ Support Modules
### Listing
This module implements listing a text file with line numbers and
optional highlights of given source lines, optionally with comments
for those lines.
(print-source-listing lines highlights context hl-pre hl-post ctx-pre ctx-post ellipsis)
* ```lines``` - list of string representing lines of the text file
* ```highlights``` - list of highlights (see below)
* ```context``` - number of context lines to be shown around highlighted lies
* ```hl-pre``` - string introducing highlighted lines
* ```hl-post``` - string terminating highlighted lines
* ```ctx-pre``` - string introducing context lines
* ```ctx-post``` - string terminating context lines
* ```ellipsis``` - string representing lines omitted from the output
Prints given text file represented by the ```lines``` list of strings.
Lines to be highlighted can be specified in the ```highlights```
list. The highlight specification is either a number or a list
containing the line number and string comment.
The lines are actually highlighted by prepending them with
```hl-pre``` string and the highlight is finished by appending
```hl-post``` to them. Usually some constants from the ```ansi```
module are used.
If some lines are highlighted a number of ```context``` lines
surrounding them may be printed as well. If this argument is negative,
all non-highlighted lines are printed as context lines.
Context lines are prepended with ```ctx-pre``` string and terminated
by ```ctx-post``` string.
If some lines between highlight and/or context lines are omitted,
```ellipsis``` string is printed on single line as a substitute.
### Progress
Provides syntax forms and procedures for showing progress of a