From 2d9a92ad0d51695e6a4e7ea457d297b7abe9d4ac Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Thu, 28 Nov 2019 22:21:54 +0530 Subject: [PATCH] Add terminal colors!!! Signed-off-by: Joseph Nuthalapati --- .gitignore | 1 + TODO.org | 7 +++++++ cli_tube.nim | 13 ++++++++----- 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 .gitignore create mode 100644 TODO.org diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3ea233a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +cli_tube diff --git a/TODO.org b/TODO.org new file mode 100644 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 diff --git a/cli_tube.nim b/cli_tube.nim index 3ed32b0..a1ba868 100644 --- a/cli_tube.nim +++ b/cli_tube.nim @@ -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( -- 2.43.0