aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2021-11-14 15:06:48 +0100
committerbptato <nincsnevem662@gmail.com>2021-11-14 15:06:48 +0100
commitf802b92f0071700e3aacf560d2a90fb47b3baf6b (patch)
tree6fea0afaf7588ef51dad727a9025cc3cf0ba0104 /src/utils
parent60b583516262be8754c6563ed9253b8964bef5d8 (diff)
downloadchawan-f802b92f0071700e3aacf560d2a90fb47b3baf6b.tar.gz
Store pixels per character/row
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/twtstr.nim20
1 files changed, 3 insertions, 17 deletions
diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim
index 27269169..6291df36 100644
--- a/src/utils/twtstr.nim
+++ b/src/utils/twtstr.nim
@@ -3,6 +3,7 @@ import strutils
import unicode
import tables
import json
+import bitops
func ansiStyle*(str: string, style: Style): seq[string] =
result &= ansiStyleCode(style)
@@ -67,26 +68,11 @@ func isControlChar*(r: Rune): bool =
of Rune(0x7F): return true
else: return false
-func genControlCharMap*(): string =
- for c in low(char)..high(char):
- if c >= 'a':
- result &= char(int(c) - int('a') + 1)
- elif c == '?':
- result &= char(127)
- else:
- result &= char(0)
-
-const controlCharMap = genControlCharMap()
-
func getControlChar*(c: char): char =
- return controlCharMap[int(c)]
+ return char(bitand(int(c), 0x1f))
func getControlLetter*(c: char): char =
- if int(c) <= 0x1F:
- return char(int(c) + int('A') - 1)
- elif c == '\x7F':
- return '?'
- assert(false)
+ return char(bitor(int(c), 0x40))
func findChar*(str: string, c: char, start: int = 0): int =
var i = start