about summary refs log tree commit diff stats
path: root/src/utils/strwidth.nim
Commit message (Collapse)AuthorAgeFilesLines
* utils: add twtunibptato2024-09-081-54/+28
| | | | | | | | | | | | | | | | | | | std/unicode has the following issues: * Rune is an int32, which implies overflow checking. Also, it is distinct, so you have to convert it manually to do arithmetic. * QJS libunicode and Chagashi work with uint32, interfacing with these required pointless type conversions. * fastRuneAt is a template, meaning it's pasted into every call site. Also, it decodes to UCS-4, so it generates two branches that aren't even used. Overall this lead to quite some code bloat. * fastRuneAt and lastRune have frustratingly different interfaces. Writing code to handle both cases is error prone. * On older Nim versions which we still support, std/unicode takes strings, not openArray[char]'s. Replace it with "twtuni", which includes some improved versions of the few procedures from std/unicode that we actually use.
* Fix 1.6.14 compilationbptato2024-09-071-1/+29
| | | | | Wait, why does std fastRuneAt try to decode UCS-32? Hmm...
* md2html: code, pre, inline fixesbptato2024-09-071-1/+1
|
* forkserver: simplify fcLoadConfigbptato2024-05-181-3/+1
|
* luwrap: use separate context (+ various cleanups)bptato2024-05-101-19/+26
| | | | | | Use a LUContext to only load required CharRanges once per pager. Also, add kana & hangul vi word break categories for convenience.
* luwrap: replace Nim unicode maps with libunicodebptato2024-05-091-27/+0
| | | | | | | | | | | | | | | | | 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.
* strwidth: return alpha for underscore in vi wordsbptato2024-04-171-1/+1
|
* Update code stylebptato2024-04-171-12/+12
| | | | | | * separate params with ; (semicolon) instead of , (colon) * reduce screaming snake case use * wrap long lines
* strwidth, renderdocument: small refactoringbptato2024-03-031-37/+20
| | | | | | * put attrs pointer in state * simplify width() * use unsigned int as ptint to avoid UB
* Re-design word handling, add e, E, W, B, etc.bptato2024-01-191-11/+19
| | | | | | | | | | | | * Add functions for moving to the beginning/end of words (vi `b', `e'). * As it turns out, there are many possible interpretations of what a word is. Now we have a function for each reasonable interpretation, and the default settings match those of vi (and w3m in w3m.toml). (Exception: it's still broken on line boundaries... TODO) * Remove `bounds` from lineedit, it was horrible API design and mostly useless. In the future, an API similar to what pager now has could be added. * Update docs, and fix some spacing issues with symbols in the tables.
* charwidth: use pre-generated map filebptato2024-01-041-136/+2
| | | | Also for reducing compilation time.
* strwidth & url fixesbptato2023-12-161-1/+1
| | | | | | * actually search Combining for isCombining * fix searchInMap * fix cmpRange of url
* charcategory: move out isDigitAsciibptato2023-12-141-0/+3
| | | | so we do not have to import unicode
* break up twtstr somewhatbptato2023-12-131-0/+246
Avoid computing e.g. charwidth data for http which does not need it at all.