about summary refs log tree commit diff stats
path: root/src/utils
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-07-05 17:54:22 +0200
committerbptato <nincsnevem662@gmail.com>2023-07-05 18:01:00 +0200
commit4511c956bf62983f1d3f0252805fadaac040123e (patch)
tree9a04a74fda5ff70316948c775c7e133d5112b426 /src/utils
parent76cb8dee5e2066a7409f53edf74b2d3275ff4a7e (diff)
downloadchawan-4511c956bf62983f1d3f0252805fadaac040123e.tar.gz
Add popup menu for select element
Replaces the weird CSS implementation we have had until now with a
searchable popup menu similar to that of w3m. (The previous
implementation broke on websites that do not expect <select> to
expand on click, had no separate search, and was ugly.)
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/twtstr.nim5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim
index f735252c..60b85cbc 100644
--- a/src/utils/twtstr.nim
+++ b/src/utils/twtstr.nim
@@ -1068,9 +1068,10 @@ func width*(s: seq[Rune], min: int): int =
     inc i
 
 func twidth*(s: string, w: int): int =
-  result = w
+  var i = 0
   for r in s.runes():
-    result += r.twidth(result)
+    i += r.twidth(result)
+  return i
 
 func breaksWord*(r: Rune): bool =
   return not (r.isDigitAscii() or r.width() == 0 or r.isAlpha())