mirror of
https://github.com/daylinmorgan/bbansi.git
synced 2024-11-22 01:10:44 -06:00
feat: start testcard implementation
This commit is contained in:
parent
48cd26b644
commit
32abc9910a
2 changed files with 19 additions and 4 deletions
|
@ -153,6 +153,19 @@ flags:
|
||||||
&"[yellow]-{s}[/] [green]--{l.alignLeft(longOptPad)}[/] {d}").join("\n ")
|
&"[yellow]-{s}[/] [green]--{l.alignLeft(longOptPad)}[/] {d}").join("\n ")
|
||||||
))
|
))
|
||||||
|
|
||||||
|
proc testCard =
|
||||||
|
for style in [
|
||||||
|
"bold", "faint", "italic", "underline",
|
||||||
|
"blink", "reverse", "conceal", "strike"]:
|
||||||
|
echo style, " -> ", bb(&"[{style}]****")
|
||||||
|
const colors = [
|
||||||
|
"black", "red", "green", "yellow",
|
||||||
|
"blue", "magenta", "cyan", "white", ]
|
||||||
|
for color in colors:
|
||||||
|
echo color, " -> ", bb(&"[{color}]****")
|
||||||
|
for color in colors:
|
||||||
|
echo "on ", color, " -> ", bb(&"[ on {color}]****")
|
||||||
|
|
||||||
proc debug(bbs: BbString): string =
|
proc debug(bbs: BbString): string =
|
||||||
echo "bbString("
|
echo "bbString("
|
||||||
echo " raw: ", bbs.raw
|
echo " raw: ", bbs.raw
|
||||||
|
@ -179,6 +192,7 @@ flags:
|
||||||
case key:
|
case key:
|
||||||
of "help", "h": writeHelp()
|
of "help", "h": writeHelp()
|
||||||
of "version", "v": writeVersion()
|
of "version", "v": writeVersion()
|
||||||
|
of "testCard": testCard(); quit(QuitSuccess)
|
||||||
of "style", "s":
|
of "style", "s":
|
||||||
if val == "":
|
if val == "":
|
||||||
echo "[red]ERROR[/]: expected value for -s/--style".bb
|
echo "[red]ERROR[/]: expected value for -s/--style".bb
|
||||||
|
|
|
@ -3,7 +3,7 @@ import std/[strtabs, strutils]
|
||||||
let bbReset* = "\e[0m"
|
let bbReset* = "\e[0m"
|
||||||
|
|
||||||
let
|
let
|
||||||
bbStyles = {
|
bbStyles* = {
|
||||||
"bold": "1",
|
"bold": "1",
|
||||||
"b": "1",
|
"b": "1",
|
||||||
"faint": "2",
|
"faint": "2",
|
||||||
|
@ -15,9 +15,10 @@ let
|
||||||
"reverse": "7",
|
"reverse": "7",
|
||||||
"conceal": "8",
|
"conceal": "8",
|
||||||
"strike": "9",
|
"strike": "9",
|
||||||
|
|
||||||
}.newStringTable(modeCaseInsensitive)
|
}.newStringTable(modeCaseInsensitive)
|
||||||
|
|
||||||
bbColors = {
|
bbColors* = {
|
||||||
"black": "0",
|
"black": "0",
|
||||||
"red": "1",
|
"red": "1",
|
||||||
"green": "2",
|
"green": "2",
|
||||||
|
@ -32,8 +33,8 @@ proc toAnsiCode*(s: string): string =
|
||||||
var
|
var
|
||||||
styles: seq[string]
|
styles: seq[string]
|
||||||
bgStyle: string
|
bgStyle: string
|
||||||
if " on " in s:
|
if " on " in s or s.startswith("on"):
|
||||||
let fgBgSplit = s.rsplit(" on ", maxsplit = 1)
|
let fgBgSplit = s.rsplit("on", maxsplit = 1)
|
||||||
styles = fgBgSplit[0].splitWhitespace()
|
styles = fgBgSplit[0].splitWhitespace()
|
||||||
bgStyle = fgBgSplit[1].strip()
|
bgStyle = fgBgSplit[1].strip()
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue