diff --git a/doc/support.md b/doc/support.md index 621b81c..50196d2 100644 --- a/doc/support.md +++ b/doc/support.md @@ -12,6 +12,8 @@ much in common. ### ANSI + (import ansi) + A simple module for creating ANSI (ECMA-48) sequence strings. (ansi . args) @@ -123,6 +125,8 @@ corner. ### Command Line parsing + (import command-line) + Generic syntax-based implementation of command-line options parsing with focus on generated help and ergonomic binding of option arguments. @@ -156,6 +160,8 @@ help strings in a nice, human-readable format. ### Listing + (import listing) + This module implements listing a text file with line numbers and optional highlights of given source lines, optionally with comments for those lines. @@ -210,6 +216,8 @@ If some lines between highlight and/or context lines are omitted, ### Progress + (import progress) + Provides syntax forms and procedures for showing progress of a process. @@ -275,8 +283,73 @@ progress% value must be updated with ```progress%-advance```. If the new-value differs from last value shown more than ```(*progress%-step*)```, redisplays the current progress%. +### Table + + (import table) + +This module provides moderately complex terminal table rendering. + + (*table-border-style* [style]) + +* ```style``` - symbol representing the style + +Valid styles are: + +* ```'debug``` - special style to see any rendering problems +* ```'ascii``` - plain ASCII (7-bit) +* ```'unicode``` - nice box-drawing table (UTF-8) + +If invalid style is provided, ```'debug``` style is automatically +substituted. + + (table->string tbl + [#:table-border #f] + [#:row-border #f] + [#:col-border #f] + [#:row0-border #f] + [#:col0-border #f] + [#:border-style (*table-border-style*)] + [#:ansi #f]) + +* ```tbl``` - list of lists with cell data +* ```#:table-border``` - if ```#t```, the table has outer border +* ```#:row-border``` - if ```#t```, the rows are separated by borders +* ```#:col-border``` - if ```#t```, the columns are separated by borders +* ```#:row0-border``` - if ```#t```, the first row is separated by border +* ```#:col0-border``` - if ```#t```, the first column is separated by border +* ```#:border-style``` - which border style to use (see + ```*table-border-style*``` which is the default) +* ```#:ansi``` - if ```#t```, all cell line strings are terminated + with ```a:default``` + +The table ```tbl``` is represented as a list of rows where each row is +a list of cells that hold arbitrary values that are converted to +string when rendering the table. + +Before rendering the table, the following steps are performed: + +* The table is made rectangular - that is all rows are extended by + empty strings to have the same length. +* All non-string cells are converted to string using ```sprintf``` +* All cells are split into list of strings representing the lines of + text inside them. +* For each row, all cells are extended by empty strings to have + matching number of lines of text inside them. +* For each column, all lines of text inside all of the cells are + padded with spaces to have uniform width. + +Then each table row is converted to list of strings adding column +separators and table borders as required. These lists are then joined +with row separators and possibly prefixed and suffixed by top and +bottom table border. + +The resulting list of strings is joined with newline character as the +separator. + ### Testing + (import testing) + This module provides simple syntax forms for (unit) testing of other modules. @@ -347,65 +420,4 @@ exception. An exception is raised if no exception was raised during the evaluation. If the test passes, prints "." like all tests from this module do. -### Table - -This module provides moderately complex terminal table rendering. - - (*table-border-style* [style]) - -* ```style``` - symbol representing the style - -Valid styles are: - -* ```'debug``` - special style to see any rendering problems -* ```'ascii``` - plain ASCII (7-bit) -* ```'unicode``` - nice box-drawing table (UTF-8) - -If invalid style is provided, ```'debug``` style is automatically -substituted. - - (table->string tbl - [#:table-border #f] - [#:row-border #f] - [#:col-border #f] - [#:row0-border #f] - [#:col0-border #f] - [#:border-style (*table-border-style*)] - [#:ansi #f]) - -* ```tbl``` - list of lists with cell data -* ```#:table-border``` - if ```#t```, the table has outer border -* ```#:row-border``` - if ```#t```, the rows are separated by borders -* ```#:col-border``` - if ```#t```, the columns are separated by borders -* ```#:row0-border``` - if ```#t```, the first row is separated by border -* ```#:col0-border``` - if ```#t```, the first column is separated by border -* ```#:border-style``` - which border style to use (see - ```*table-border-style*``` which is the default) -* ```#:ansi``` - if ```#t```, all cell line strings are terminated - with ```a:default``` - -The table ```tbl``` is represented as a list of rows where each row is -a list of cells that hold arbitrary values that are converted to -string when rendering the table. - -Before rendering the table, the following steps are performed: - -* The table is made rectangular - that is all rows are extended by - empty strings to have the same length. -* All non-string cells are converted to string using ```sprintf``` -* All cells are split into list of strings representing the lines of - text inside them. -* For each row, all cells are extended by empty strings to have - matching number of lines of text inside them. -* For each column, all lines of text inside all of the cells are - padded with spaces to have uniform width. - -Then each table row is converted to list of strings adding column -separators and table borders as required. These lists are then joined -with row separators and possibly prefixed and suffixed by top and -bottom table border. - -The resulting list of strings is joined with newline character as the -separator. - ### Environment diff --git a/src/ansi.scm b/src/ansi.scm index 41f330f..4a05ab7 100644 --- a/src/ansi.scm +++ b/src/ansi.scm @@ -29,6 +29,7 @@ ansi ( ansi + a:error a:warning a:success @@ -36,6 +37,7 @@ a:default a:muted a:highlight + ansi-string-length ansi-paragraph-format ansi-string diff --git a/src/command-line.scm b/src/command-line.scm index b677587..8bc5e65 100644 --- a/src/command-line.scm +++ b/src/command-line.scm @@ -29,8 +29,10 @@ command-line ( command-line + command-line:parse-command-line command-line:print-options + command-line-tests! ) diff --git a/src/listing.scm b/src/listing.scm index 575bdf9..0299d33 100644 --- a/src/listing.scm +++ b/src/listing.scm @@ -29,6 +29,7 @@ listing ( print-source-listing + listing-tests! )