about summary refs log tree commit diff stats
path: root/src/utils
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-07-13 23:03:53 +0200
committerbptato <nincsnevem662@gmail.com>2022-07-13 23:55:59 +0200
commit8ab202fa89941e9f528858b2e9e35cf39ad7043f (patch)
tree1bb80e2d0b138480832485ec682f9779f37b47ec /src/utils
parentc0d6e76d94a25cbeb7d4f0aff9bc79c733f10fd5 (diff)
downloadchawan-8ab202fa89941e9f528858b2e9e35cf39ad7043f.tar.gz
Throw out unused functions
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/twtstr.nim101
1 files changed, 0 insertions, 101 deletions
diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim
index 9799f5d1..00f56905 100644
--- a/src/utils/twtstr.nim
+++ b/src/utils/twtstr.nim
@@ -2,8 +2,6 @@ import algorithm
 import terminal
 import strutils
 import unicode
-import tables
-import json
 import os
 import math
 import sugar
@@ -893,102 +891,3 @@ func padToWidth*(str: string, size: int, schar = '$'): string =
         result &= r
         w += r.width
     result &= schar
-
-const CanHaveDakuten = "かきくけこさしすせそたちつてとはひふへほカキクケコサシスセソタチツテトハヒフヘホ".toRunes()
-
-const CanHaveHandakuten = "はひふへほハヒフヘホ".toRunes()
-
-const HasDakuten = "がぎぐげござじずぜぞだぢづでどばびぶべぼガギグゲゴザジゼゾダヂヅデドバビブベボ".toRunes()
-
-const HasHanDakuten = "ぱぴぷぺぽパピプペポ".toRunes()
-
-#in unicode, char + 1 is dakuten and char + 2 handakuten
-#゙゚
-
-const HalfDakuten = "゙".toRunes()[0]
-const HalfHanDakuten = "゚".toRunes()[0]
-
-const Dakuten = Rune(0x3099)
-const HanDakuten = Rune(0x309A)
-
-func dakuten*(r: Rune): Rune =
-  if r in CanHaveDakuten:
-    return cast[Rune](cast[int](r) + 1)
-  return r
-
-func handakuten*(r: Rune): Rune =
-  if r in CanHaveHandakuten:
-    return cast[Rune](cast[int](r) + 2)
-  return r
-
-func nodakuten*(r: Rune): Rune =
-  return cast[Rune](cast[int](r) - 1)
-
-func nohandakuten*(r: Rune): Rune =
-  return cast[Rune](cast[int](r) - 2)
-
-# Halfwidth to fullwidth & vice versa
-const widthconv = staticRead"res/widthconv.json"
-proc genHalfWidthTable(): Table[Rune, Rune] =
-  let widthconvjson = parseJson(widthconv)
-  for k, v in widthconvjson:
-    if v.kind == JString:
-      result[v.getStr().toRunes()[0]] = k.toRunes()[0]
-    else:
-      for s in v:
-        result[s.getStr().toRunes()[0]] = k.toRunes()[0]
-
-proc genFullWidthTable(): Table[Rune, Rune] =
-  let widthconvjson = parseJson(widthconv)
-  for k, v in widthconvjson:
-    if v.kind == JString:
-      result[k.toRunes()[0]] = v.getStr().toRunes()[0]
-    else:
-      result[k.toRunes()[0]] = v[0].getStr().toRunes()[0]
-
-const halfwidthtable = genHalfWidthTable()
-const fullwidthtable = genFullWidthTable()
-
-func halfwidth*(r: Rune): Rune =
-  return halfwidthtable.getOrDefault(r, r)
-
-func halfwidth*(s: seq[Rune]): seq[Rune] =
-  for r in s:
-    #TODO combining dakuten don't always work with half width chars
-    #a proper solution would be something like:
-    #* try to detect if they work, if not fallback to halfwidth handakuten
-    #* add a config option for overriding this
-    #* also add an option to completely ignore dakuten
-    #* and one to disable half width ruby of course
-    if r in HasDakuten:
-      result.add(halfwidth(r.nodakuten()))
-      result.add(Dakuten)
-    elif r in HasHanDakuten:
-      result.add(halfwidth(r.nohandakuten()))
-      result.add(HanDakuten)
-    else:
-      result.add(halfwidth(r))
-
-func halfwidth*(s: string): string =
-  return $halfwidth(s.toRunes())
-
-func fullwidth*(r: Rune): Rune =
-  return fullwidthtable.getOrDefault(r, r)
-
-proc fullwidth*(s: seq[Rune]): seq[Rune] =
-  for r in s:
-    if r == Rune(0xFF9E): #dakuten
-      if result.len > 0:
-        result[^1] = result[^1].dakuten()
-      else:
-        result.add(r)
-    elif r == Rune(0xFF9F): #handakuten
-      if result.len > 0:
-        result[^1] = result[^1].handakuten()
-      else:
-        result.add(r)
-    else:
-      result.add(fullwidth(r))
-
-proc fullwidth*(s: string): string =
-  return $fullwidth(s.toRunes())