|
|
@ -137,11 +137,31 @@ tcl::namespace::eval textblock { |
|
|
|
return " -choices \{$choices\} -help {algorithm choice $choicemsg} " |
|
|
|
return " -choices \{$choices\} -help {algorithm choice $choicemsg} " |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
namespace eval argdoc { |
|
|
|
|
|
|
|
tcl::namespace::import ::punk::ansi::a+ |
|
|
|
|
|
|
|
# -- --- --- --- --- |
|
|
|
|
|
|
|
#non colour SGR codes |
|
|
|
|
|
|
|
# we can use these directly via ${$I} etc without marking a definition with @dynamic |
|
|
|
|
|
|
|
#This is because they don't need to change when colour switched on and off. |
|
|
|
|
|
|
|
set I [a+ italic] |
|
|
|
|
|
|
|
set NI [a+ noitalic] |
|
|
|
|
|
|
|
set B [a+ bold] |
|
|
|
|
|
|
|
set N [a+ normal] |
|
|
|
|
|
|
|
# -- --- --- --- --- |
|
|
|
|
|
|
|
proc example {str} { |
|
|
|
|
|
|
|
set str [string trimleft $str \n] |
|
|
|
|
|
|
|
set block [punk::ansi::ansiwrap Web-gray [textblock::frame -ansibase [a+ Web-gray bold white] -ansiborder [a+ black White] -boxlimits {hl} -type block $str]] |
|
|
|
|
|
|
|
set result [textblock::bookend_lines $block [a] "[a defaultbg] [a]"] |
|
|
|
|
|
|
|
#puts $result |
|
|
|
|
|
|
|
return $result |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# hash_algorithm -optional 1 -choices {${[::textblock::argdoc::hash_algorithm_choices]}} -help\ |
|
|
|
# hash_algorithm -optional 1 -choices {${[::textblock::argdoc::hash_algorithm_choices]}} -help\ |
|
|
|
# "algorithm choice" |
|
|
|
# "algorithm choice" |
|
|
|
namespace eval argdoc { |
|
|
|
namespace eval argdoc { |
|
|
|
set DYN_HASH_ALGORITHM_CHOICES_AND_HELP {$[::textblock::argdoc::hash_algorithm_choices_and_help]} |
|
|
|
set DYN_HASH_ALGORITHM_CHOICES_AND_HELP {${[::textblock::argdoc::hash_algorithm_choices_and_help]}} |
|
|
|
punk::args::define { |
|
|
|
punk::args::define { |
|
|
|
@dynamic |
|
|
|
@dynamic |
|
|
|
@id -id ::textblock::use_hash |
|
|
|
@id -id ::textblock::use_hash |
|
|
@ -7769,75 +7789,93 @@ tcl::namespace::eval textblock { |
|
|
|
# ${[textblock::frame_samples]} |
|
|
|
# ${[textblock::frame_samples]} |
|
|
|
|
|
|
|
|
|
|
|
#todo punk::args alias for centre center etc? |
|
|
|
#todo punk::args alias for centre center etc? |
|
|
|
punk::args::define { |
|
|
|
namespace eval argdoc { |
|
|
|
@dynamic |
|
|
|
punk::args::define { |
|
|
|
@id -id ::textblock::frame |
|
|
|
@dynamic |
|
|
|
@cmd -name "textblock::frame"\ |
|
|
|
@id -id ::textblock::frame |
|
|
|
-help "Frame a block of text with a border." |
|
|
|
@cmd -name "textblock::frame"\ |
|
|
|
-checkargs -default 1 -type boolean\ |
|
|
|
-summary "Frame a block of content with a border."\ |
|
|
|
-help "If true do extra argument checks and |
|
|
|
-help\ |
|
|
|
provide more comprehensive error info. |
|
|
|
"This command allows content to be framed with various border styles. The content can include |
|
|
|
As the argument parser loads around 16 default frame |
|
|
|
other ANSI codes and unicode characters. Some predefined border types can be selected with |
|
|
|
samples dynamically, this can add add up as each may |
|
|
|
the -type option and the characters can be overridden either in part or in total by supplying |
|
|
|
take 10s of microseconds. For many-framed tables |
|
|
|
some or all entries in the -boxmap dictionary. |
|
|
|
and other applications this can add up. |
|
|
|
The ${$B}textblock::framedef${$N} command can be used to return a dictionary for a frame type. |
|
|
|
Set false for performance improvement." |
|
|
|
Border elements can also be suppressed on chosen sides with -boxlimits. |
|
|
|
-etabs -default 0\ |
|
|
|
ANSI colours can be applied to borders or as defaults for the content using -ansiborder and |
|
|
|
-help "expanding tabs - experimental/unimplemented." |
|
|
|
-ansibase options. |
|
|
|
-type -default light -choices {${[textblock::frametypes]}} -choicerestricted 0 -choicecolumns 8 -type dict\ |
|
|
|
The punk::ansi::a+ function (aliased as a+) can be used to apply ANSI styles. |
|
|
|
-choicelabels { |
|
|
|
e.g |
|
|
|
${[textblock::frame_samples]} |
|
|
|
frame -type block -ansiborder [a+ blue Red] -ansibase [a+ black Red] \"A\\nB\"" |
|
|
|
}\ |
|
|
|
-checkargs -default 1 -type boolean\ |
|
|
|
-help "Type of border for frame." |
|
|
|
-help "If true do extra argument checks and |
|
|
|
-boxlimits -default {hl vl tlc blc trc brc} -type list -help "Limit the border box to listed elements. |
|
|
|
provide more comprehensive error info. |
|
|
|
passing an empty string will result in no box, but title/subtitle will still appear if supplied. |
|
|
|
As the argument parser loads around 16 default frame |
|
|
|
${[textblock::EG]}e.g: -frame -boxlimits {} -title things [a+ red White]my\\ncontent${[textblock::RST]}" |
|
|
|
samples dynamically, this can add add up as each may |
|
|
|
-boxmap -default {} -type dict |
|
|
|
take 10s of microseconds. For many-framed tables |
|
|
|
-joins -default {} -type list |
|
|
|
and other applications this can add up. |
|
|
|
-title -default "" -type string -regexprefail {\n}\ |
|
|
|
Set false for performance improvement." |
|
|
|
-help "Frame title placed on topbar - no newlines. |
|
|
|
-etabs -default 0\ |
|
|
|
May contain ANSI - no trailing reset required. |
|
|
|
-help "expanding tabs - experimental/unimplemented." |
|
|
|
${[textblock::EG]}e.g 1: frame -title My[a+ green]Green[a]Thing |
|
|
|
-type -default light\ |
|
|
|
e.g 2: frame -title [a+ red underline]MyThing${[textblock::RST]}" |
|
|
|
-type dict\ |
|
|
|
-titlealign -default "centre" -choices {left centre right} |
|
|
|
-typesynopsis {${$I}choice${$NI}|<${$I}dict${$NI}>}\ |
|
|
|
-subtitle -default "" -type string -regexprefail {\n}\ |
|
|
|
-choices {${[textblock::frametypes]}}\ |
|
|
|
-help "Frame subtitle placed on bottombar - no newlines |
|
|
|
-choicerestricted 0 -choicecolumns 8\ |
|
|
|
May contain Ansi - no trailing reset required." |
|
|
|
-choicelabels { |
|
|
|
-subtitlealign -default "centre" -choices {left centre right} |
|
|
|
${[textblock::frame_samples]} |
|
|
|
-width -default "" -type int\ |
|
|
|
}\ |
|
|
|
-help "Width of resulting frame including borders. |
|
|
|
-help "Type of border for frame." |
|
|
|
If omitted or empty-string, the width will be determined automatically based on content." |
|
|
|
-boxlimits -default {hl vl tlc blc trc brc} -type list -help "Limit the border box to listed elements. |
|
|
|
-height -default "" -type int\ |
|
|
|
passing an empty string will result in no box, but title/subtitle will still appear if supplied. |
|
|
|
-help "Height of resulting frame including borders." |
|
|
|
${[textblock::EG]}e.g: -frame -boxlimits {} -title things [a+ red White]my\\ncontent${[textblock::RST]}" |
|
|
|
-ansiborder -default "" -type ansistring\ |
|
|
|
-boxmap -default {} -type dict |
|
|
|
-help "Ansi escape sequence to set border attributes. |
|
|
|
-joins -default {} -type list |
|
|
|
${[textblock::EG]}e.g 1: frame -ansiborder [a+ web-red] contents |
|
|
|
-title -default "" -type string -regexprefail {\n}\ |
|
|
|
e.g 2: frame -ansiborder \"\\x1b\\\[31m\" contents${[textblock::RST]}" |
|
|
|
-help "Frame title placed on topbar - no newlines. |
|
|
|
-ansibase -default "" -type ansistring\ |
|
|
|
May contain ANSI - no trailing reset required. |
|
|
|
-help "Default ANSI attributes within frame." |
|
|
|
${[textblock::EG]}e.g 1: frame -title My[a+ green]Green[a]Thing |
|
|
|
-blockalign -default centre -choices {left right centre}\ |
|
|
|
e.g 2: frame -title [a+ red underline]MyThing${[textblock::RST]}" |
|
|
|
-help "Alignment of the content block within the frame." |
|
|
|
-titlealign -default "centre" -choices {left centre right} |
|
|
|
-pad -default 1 -type boolean -help "Whether to pad within the ANSI so content background |
|
|
|
-subtitle -default "" -type string -regexprefail {\n}\ |
|
|
|
extends within the content block inside the frame. |
|
|
|
-help "Frame subtitle placed on bottombar - no newlines |
|
|
|
Has no effect if no ANSI in content." |
|
|
|
May contain Ansi - no trailing reset required." |
|
|
|
-textalign -default left -choices {left right centre}\ |
|
|
|
-subtitlealign -default "centre" -choices {left centre right} |
|
|
|
-help "Alignment of text within the content block. (centre unimplemented)" |
|
|
|
-width -default "" -type int\ |
|
|
|
-ellipsis -default 1 -type boolean\ |
|
|
|
-help "Width of resulting frame including borders. |
|
|
|
-help "Whether to show elipsis for truncated content and title/subtitle." |
|
|
|
If omitted or empty-string, the width will be determined automatically based on content." |
|
|
|
-usecache -default 1 -type boolean |
|
|
|
-height -default "" -type int\ |
|
|
|
-buildcache -default 1 -type boolean |
|
|
|
-help "Height of resulting frame including borders." |
|
|
|
-crm_mode -default 0 -type boolean\ |
|
|
|
-ansiborder -default "" -type ansistring\ |
|
|
|
-help "Show ANSI control characters within frame contents. |
|
|
|
-help "Ansi escape sequence to set border attributes. |
|
|
|
(Control Representation Mode) |
|
|
|
${[textblock::EG]}e.g 1: frame -ansiborder [a+ web-red] contents |
|
|
|
Frame width doesn't adapt and content may be truncated |
|
|
|
e.g 2: frame -ansiborder \"\\x1b\\\[31m\" contents${[textblock::RST]}" |
|
|
|
so -width may need to be manually set to display more." |
|
|
|
-ansibase -default "" -type ansistring\ |
|
|
|
|
|
|
|
-help "Default ANSI attributes within frame." |
|
|
|
|
|
|
|
-blockalign -default centre -choices {left right centre}\ |
|
|
|
|
|
|
|
-help "Alignment of the content block within the frame." |
|
|
|
|
|
|
|
-pad -default 1 -type boolean -help "Whether to pad within the ANSI so content background |
|
|
|
|
|
|
|
extends within the content block inside the frame. |
|
|
|
|
|
|
|
Has no effect if no ANSI in content." |
|
|
|
|
|
|
|
-textalign -default left -choices {left right centre}\ |
|
|
|
|
|
|
|
-help "Alignment of text within the content block. (centre unimplemented)" |
|
|
|
|
|
|
|
-ellipsis -default 1 -type boolean\ |
|
|
|
|
|
|
|
-help "Whether to show elipsis for truncated content and title/subtitle." |
|
|
|
|
|
|
|
-usecache -default 1 -type boolean |
|
|
|
|
|
|
|
-buildcache -default 1 -type boolean |
|
|
|
|
|
|
|
-crm_mode -default 0 -type boolean\ |
|
|
|
|
|
|
|
-help "Show ANSI control characters within frame contents. |
|
|
|
|
|
|
|
(Control Representation Mode) |
|
|
|
|
|
|
|
Frame width doesn't adapt and content may be truncated |
|
|
|
|
|
|
|
so -width may need to be manually set to display more." |
|
|
|
|
|
|
|
|
|
|
|
@values -min 0 -max 1 |
|
|
|
@values -min 0 -max 1 |
|
|
|
contents -default "" -type string\ |
|
|
|
contents -default "" -type string\ |
|
|
|
-help "Frame contents - may be a block of text containing newlines and ANSI. |
|
|
|
-help "Frame contents - may be a block of text containing newlines and ANSI. |
|
|
|
Text may be 'ragged' - ie unequal line-lengths. |
|
|
|
Text may be 'ragged' - ie unequal line-lengths. |
|
|
|
No trailing ANSI reset required. |
|
|
|
No trailing ANSI reset required. |
|
|
|
${[textblock::EG]}e.g: frame \"[a+ blue White] \\nMy blue foreground text on\\nwhite background\\n\"${[textblock::RST]}" |
|
|
|
${[textblock::EG]}e.g: frame \"[a+ blue White] \\nMy blue foreground text on\\nwhite background\\n\"${[textblock::RST]}" |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#options before content argument - which is allowed to be absent |
|
|
|
#options before content argument - which is allowed to be absent |
|
|
|