]> njoseph.me Git - nimcoon.git/commitdiff
Add terminal colors!!!
authorJoseph Nuthalapati <njoseph@riseup.net>
Thu, 28 Nov 2019 16:51:54 +0000 (22:21 +0530)
committerJoseph Nuthalapati <njoseph@riseup.net>
Thu, 28 Nov 2019 16:51:54 +0000 (22:21 +0530)
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
.gitignore [new file with mode: 0644]
TODO.org [new file with mode: 0644]
cli_tube.nim

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..3ea233a
--- /dev/null
@@ -0,0 +1 @@
+cli_tube
diff --git a/TODO.org b/TODO.org
new file mode 100644 (file)
index 0000000..0377b89
--- /dev/null
+++ b/TODO.org
@@ -0,0 +1,7 @@
+#+TITLE: TODO
+
+# No point to having GitLab issues for a one-man project
+
+* TODO Pretty colors in terminal
+* TODO Preferences should go into a config file
+* TODO Terminal color themes
index 3ed32b0ec78e70edbd5c6dc1ae348a45af0a238d..a1ba868a8c0d5c45e045a4b6885a153c7770a451 100644 (file)
@@ -8,13 +8,16 @@ import strutils
 import uri
 import xmltree
 
-# TODO Pretty colors in terminal
-# import terminal
-
 # Supported video players in order of preference
-# TODO Should go into a config file
 let supportedPlayers = @["mpv", "mplayer", "vlc"]
 
+# Hard-coded terminal colors
+proc reset(): string {.procvar.} = "\e[0m"
+proc bold*(s: string): string {.procvar.} = "\e[1m" & s & reset()
+
+proc fgMagenta*(s: string): string {.procvar.} = "\e[35m" & s & reset()
+proc fgCyan*(s: string): string {.procvar.} = "\e[36m" & s & reset()
+
 type SearchResult = tuple[title: string, url: string]
 
 proc selectMediaPlayer(): string =
@@ -40,7 +43,7 @@ proc extractTitlesAndUrls(htmlFile: string): seq[SearchResult] =
 
 proc presentVideoOptions(searchResults: seq[SearchResult]) =
   for index, (title, url) in searchResults:
-    echo index, ". ", title, "\n", url, "\n"
+    echo index, ". ", title.bold.fgMagenta, "\n", url.fgCyan, "\n"
 
 presentVideoOptions(
   extractTitlesAndUrls(