about summary refs log tree commit diff stats
path: root/twtstr.nim
diff options
context:
space:
mode:
Diffstat (limited to 'twtstr.nim')
-rw-r--r--twtstr.nim15
1 files changed, 4 insertions, 11 deletions
diff --git a/twtstr.nim b/twtstr.nim
index 5a41f3e3..983d58d8 100644
--- a/twtstr.nim
+++ b/twtstr.nim
@@ -1,21 +1,11 @@
 import terminal
 import strutils
 
-func stripNewline*(str: string): string =
-  if str.len == 0:
-    result = str
-    return
-
-  case str[^1]
-  of '\n':
-    result = str.substr(0, str.len - 2)
-  else: discard
-
 func addAnsiStyle*(str: string, style: Style): string =
   return ansiStyleCode(style) & str & "\e[0m"
 
 func addAnsiFgColor*(str: string, color: ForegroundColor): string =
-  return ansiForegroundColorCode(color) & str & "\e[0m"
+  return ansiForegroundColorCode(color) & str & ansiResetCode
 
 func maxString*(str: string, max: int): string =
   if max < str.len:
@@ -26,3 +16,6 @@ func fitValueToSize*(str: string, size: int): string =
   if str.len < size:
     return str & ' '.repeat(size - str.len)
   return str.maxString(size)
+
+func buttonStr*(str: string): string =
+  return "[".addAnsiFgColor(fgRed) & str.addAnsiFgColor(fgRed) & "]".addAnsiFgColor(fgRed)