From 2453c63b0b12baa9bd78c0a114b58f1c3833e967 Mon Sep 17 00:00:00 2001 From: bptato Date: Thu, 9 May 2024 21:57:00 +0200 Subject: luwrap: replace Nim unicode maps with libunicode Instead of using the built-in (and outdated, and buggy) tables, we now use libunicode from QJS. This shaves some bytes off the executable, though far less than I had imagined it would. Also, a surprising effect of this change: because libunicode's tables aren't glitched out, kanji properly gets classified as alpha. I found this greatly annoying because `w' in Japanese text would now jump through whole sentences. As a band-aid solution I added an extra Han category, but I wish we had a more robust solution that could differentiate between *all* scripts. TODO: I suspect that separately loading the tables for every rune in breaksViWordCat is rather inefficient. Using some context object (at least per operation) would probably be beneficial. --- src/local/container.nim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/local/container.nim') diff --git a/src/local/container.nim b/src/local/container.nim index e4901902..985e45ef 100644 --- a/src/local/container.nim +++ b/src/local/container.nim @@ -12,8 +12,8 @@ import io/promise import io/serversocket import io/socketstream import js/javascript -import js/jstypes import js/jsregex +import js/jstypes import layout/renderdocument import loader/headers import loader/loader @@ -26,9 +26,11 @@ import types/cookie import types/referrer import types/url import types/winattrs +import utils/luwrap import utils/mimeguess import utils/strwidth import utils/twtstr +import utils/wordbreak import chagashi/charset @@ -595,7 +597,7 @@ proc cursorLineTextStart(container: Container) {.jsfunc.} = if container.numLines == 0: return var x = 0 for r in container.currentLine.runes: - if not r.isWhitespace(): + if not r.isWhiteSpaceLU(): break x += r.twidth(x) if x == 0: -- cgit 1.4.1-2-gfad0