aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2021-08-05 22:57:38 +0200
committerbptato <nincsnevem662@gmail.com>2021-08-05 23:13:55 +0200
commitb94597a68eb8572cf8f521ee9c39cc7d9d310827 (patch)
treea487471466f80a4e95cfefb4d7084f29a840eacc /src/utils
parent087f830528b41b00d0bf7a501f7b0472f75ffb18 (diff)
downloadchawan-b94597a68eb8572cf8f521ee9c39cc7d9d310827.tar.gz
Implement new buffer model which supports X coords
...also, one can kinda use this as a file viewer now I guess
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/eprint.nim11
-rw-r--r--src/utils/radixtree.nim3
-rw-r--r--src/utils/termattrs.nim11
-rw-r--r--src/utils/twtstr.nim8
4 files changed, 14 insertions, 19 deletions
diff --git a/src/utils/eprint.nim b/src/utils/eprint.nim
new file mode 100644
index 00000000..23248363
--- /dev/null
+++ b/src/utils/eprint.nim
@@ -0,0 +1,11 @@
+{.used.}
+
+template eprint*(s: varargs[string, `$`]) = {.cast(noSideEffect).}:
+ var a = false
+ for x in s:
+ if not a:
+ a = true
+ else:
+ stderr.write(' ')
+ stderr.write(x)
+ stderr.write('\n')
diff --git a/src/utils/radixtree.nim b/src/utils/radixtree.nim
index dd0a6a1d..b361d367 100644
--- a/src/utils/radixtree.nim
+++ b/src/utils/radixtree.nim
@@ -1,6 +1,5 @@
# Radix tree implementation. It isn't that much faster than a hash table,
-# however it *is* faster. Use StaticRadixTree for saving trees in the
-# executable and RadixNode otherwise (which needs less bounds checking).
+# however it *is* faster.
import json
import tables
diff --git a/src/utils/termattrs.nim b/src/utils/termattrs.nim
deleted file mode 100644
index d49800ae..00000000
--- a/src/utils/termattrs.nim
+++ /dev/null
@@ -1,11 +0,0 @@
-import terminal
-
-type
- TermAttributes* = object
- termWidth*: int
- termHeight*: int
-
-proc getTermAttributes*(): TermAttributes =
- let attrs = TermAttributes(termWidth: terminalWidth(),
- termHeight: terminalHeight())
- return attrs
diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim
index 730f8b32..22207e2c 100644
--- a/src/utils/twtstr.nim
+++ b/src/utils/twtstr.nim
@@ -211,8 +211,7 @@ iterator split*(s: seq[Rune], sep: Rune): seq[Rune] =
#
# - The null character (U+0000) has a column width of 0.
#
-# - Other C0/C1 control characters and DEL will lead to a return value of 2
-# (changed from 0 b/c we normally display control chars like ^H - TODO?).
+# - Other C0/C1 control characters and DEL will lead to a return value of 0
#
# - Non-spacing and enclosing combining characters (general category code Mn
# or Me in the Unicode database) have a column width of 0.
@@ -305,7 +304,7 @@ func is_dwidth(r: Rune): bool =
func makewidthtable(): array[0..0x10FFFF, byte] =
for r in low(char)..high(char):
if r.isControlChar():
- result[int(r)] = 2
+ result[int(r)] = 2 #TODO this should be 0
else:
result[int(r)] = 1
@@ -545,6 +544,3 @@ proc fullwidth*(s: seq[Rune]): seq[Rune] =
proc fullwidth*(s: string): string =
return $fullwidth(s.toRunes())
-
-echo (halfwidth("とうギょう"))
-echo "東京"