about summary refs log tree commit diff stats
path: root/src/utils/twtstr.nim
Commit message (Collapse)AuthorAgeFilesLines
* Eliminate some superfluous copiesbptato2025-05-111-7/+7
|
* twtstr: re-validate UTF-8 in nextUTF8bptato2025-05-111-36/+40
| | | | | it isn't used on invalid UTF-8, but the validation logic is separate so it seems better to double-check
* url, twtstr: misc cleanup, fix overflow check in parseUInt8bptato2025-05-011-4/+10
|
* url, twtstr: misc cleanupbptato2025-03-291-22/+14
|
* newhttp: drop libcurl dependencybptato2025-03-211-0/+1
| | | | Now it only does HTTP/1.1, with Connection: close.
* twtstr: normalize char constantsbptato2025-03-131-7/+7
|
* Add annotations for move semanticsbptato2025-01-221-2/+1
| | | | | | | | | Supposedly they aren't broken in refc after 2.0.0, so we can do this now that 1.6.14 is dropped. I've confirmed lent to work as advertised; it indeed reduces copies. sink doesn't seem to help much, but I guess it will be useful once we switch to ORC.
* cssvalues: serialize quotes, add font-size, opacitybptato2025-01-161-0/+7
| | | | | | | | | | | | font-size isn't very useful, but some scripts assume it exists. opacity: 0 for now is special cased: it inhibits rendering of further boxes. This isn't quite right, as it should just behave as a pseudo visibility: hidden... nonetheless it's quite effective at hiding garbage. (Also, remove incorrect comment - it can be nil if the branch has no variables.)
* config: switch to camel casebptato2025-01-131-9/+5
| | | | | | We already need a camel -> kebab converter anyway. Unfortunately this also changes JS binding names, so it's a breaking change. Oh well.
* cssvalues: reduce CSSValues sizebptato2025-01-121-8/+8
| | | | | | | | | | | | | | | | * switch from float64 -> float32; other browsers use 32-bit floats too * specify integer size as 32-bit * use NetworkBitmap for background-image value (currently just an invalid dummy value) * remove "none" property & value types CSSValue's payload is always one word (plus another for the type tag). CSSValues keeps its size, but no longer has to heap-alloc + refcount word-sized CSSValues. (On 32-bit systems, CSSValues might actually be larger than before, but I expect it's still a net benefit with the removal of refcounting and the switch to 32-bit floats.)
* twtstr: optimize a bitbptato2025-01-031-23/+19
|
* Misc character display fixesbptato2024-12-221-11/+15
| | | | | | | | | | | | | | | | | | * fix luwrap comparison function * strip high unicode controls in term/pager * use wcwidth in dirlist2html * remove combining category from strwidth * remove unused "disallowed" field from lineedit My initial goal with switching to wcwidth in dirlist2html was just to get rid of the outdated combining map in charwidth_gen. Then I realized that layout will normalize those out anyway, so we don't actually have to deal with them anywhere. Also, I found a few bugs in the process; high unicode control chars not being stripped out was a particularly bad one, as it allows for pages to mess up the terminal output. (Easiest way to replicate: just open a random binary file without this patch.)
* Add historybptato2024-12-171-2/+2
| | | | | It's still missing a "color visited links" feature, but it's better than nothing.
* twtstr: improve content type parameter handlingbptato2024-12-221-3/+28
| | | | | * accept quoted-string * quote values in setContentTypeAttr
* default(T) -> T.default, add some strict defsbptato2024-12-171-1/+2
|
* twtstr: fix skipBlanksTillLFbptato2024-12-121-1/+1
|
* twtstr: reduce copying in atobbptato2024-12-121-4/+6
|
* pager, mailcap: misc fixes, add prompt for global mailcapbptato2024-12-111-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | In the past, Chawan would read global mailcap (/etc/mailcap, ...) too, but every now and then that would run entries that I didn't even know existed and definitely didn't intend to run. So I changed it to only use ~/.mailcap, but this meant users now had to add mailcap entries for every single mime type. At some point I also changed application/octet-stream to always save to disk, which is usually nice except when a text file is misrecognized as binary. Often times I just want to decide myself what to do. So now there are two layers. First, the global mailcap files (path as per RFC) prompt before executing. Then there is ~/.chawan/auto.mailcap (or ~/.config/chawan/auto.mailcap) which runs entries automatically. If you press shift before selecting an option in the prompt, the corresponding entry gets copied to auto.mailcap. It's also possible to type a new entry on the fly. Overall I think it's quite convenient. One unfortunate side effect is that existing users will have to migrate their entries to auto.mailcap, or redefine external.auto-mailcap to e.g. ~/.mailcap, but this seems acceptable.
* twtstr: small cleanupbptato2024-12-111-9/+7
|
* mimetypes: refactor, use mime.types for inline image extensionsbptato2024-12-051-1/+18
| | | | | | | | | | | | * remove std/streams use from mime.types; mmap and parse directly * use mime.types for inline image extensions * add some jpeg file extensions Latter came up because I was trying to add a format locally and it wouldn't recognize it on images from my file system (i.e. by extension). As a security measure we still do not allow additional extensions for predefined inline image types.
* twtstr: add mypairsbptato2024-11-281-0/+9
| | | | | This couldn't get into system.nim for technical reasons, but it's still pretty useful when iterating over non-mutable openArrays.
* twtstr: beforeLast -> untilLastbptato2024-11-151-2/+2
| | | | for consistency
* luwrap: fix compilation on 2.0.8 and refactor a bitbptato2024-11-051-3/+0
| | | | ref. https://todo.sr.ht/~bptato/chawan/21
* utils, types: merge some modulesbptato2024-11-031-3/+108
| | | | | * line, vector, matrix -> path * twtuni, charcategory -> twtstr
* config: refactor, accept more possible config dirsbptato2024-10-281-0/+6
| | | | | | | | | | | | | | | | | | | | | I'm starting to favor dotfiles over XDG basedirs, but there's no reason why we couldn't have both. So now the search path is: 0. if config was set through -C, use that 1. $CHA_CONFIG_DIR is set -> $CHA_CONFIG_DIR/config.toml 2. $XDG_CONFIG_HOME is set -> $XDG_CONFIG_HOME/chawan/config.toml 3. ~/.config/chawan/config.toml exists -> use that 4. ~/.chawan/config.toml exists -> use that Notably, this makes it so the default directory is ~/.chawan *if* you don't have an existing config.toml file. So in that case known_hosts will be placed in ~/.chawan/known_hosts. However, configurations with a config in ~/.config/chawan/config.toml continue to work as expected, as for those the known_hosts file remains inside ~/.config/chawan/. Finally, I've added a default user CGI directory to reduce friction in setting CGI up. (Like known_hosts, it's also relative to whatever config dir you have.)
* twtstr, toml: misc cleanupbptato2024-10-131-0/+3
| | | | | * remove unused DateTime toml type * add parseIntP for pointer-size int parsing
* base64: merge into twtstr/envbptato2024-10-131-0/+41
|
* twtstr: fix stripAndCollapsebptato2024-10-081-11/+9
|
* twtstr: misc refactoringsbptato2024-10-011-3/+3
|
* term: refactorbptato2024-09-231-0/+3
| | | | | * reduce copies & allocations * simplify SGR generation
* twtstr: simplify integer parsingbptato2024-09-211-86/+65
| | | | | | * simplify uint parser * use uint parser for signed ints too (to simplify overflow handling) * use openArray[char] where possible
* utils: add twtunibptato2024-09-081-11/+9
| | | | | | | | | | | | | | | | | | | 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.
* md2html: code, pre, inline fixesbptato2024-09-071-2/+2
|
* twtstr: type erase binarySearch instantiationbptato2024-09-061-28/+38
| | | | | | | | Do it like parseEnumNoCase0, so we no longer instantiate a gazillion different binary searches for the same type. While we're at it, make matchNameProduction's searchInMap use uint32 too.
* xhr: progressbptato2024-08-131-0/+2
| | | | | | | | | | | | | * fix header case sensitivity issues -> probably still wrong as it discards the original casing. better than nothing, anyway * fix fulfill on generic promises * support standard open() async parameter weirdness * refactor loader response body reading (so bodyRead is no longer mandatory) * actually read response body still missing: response body getters
* dom: fix crash on wrong image content typebptato2024-08-111-0/+3
| | | | + slightly optimize getContentType
* twtstr: don't cast in parseEnumbptato2024-08-091-2/+2
| | | | Nim 1.6 does not like it.
* cssvalues, twtstr, mediaquery: refactor & fixesbptato2024-08-021-28/+25
| | | | | | | * cssvalues, twtstr: unify enum parsing code paths, parse enums by bisearch instead of hash tables * mediaquery: refactor (long overdue), fix range comparison syntax parsing, make ident comparisons case-insensitive (as they should be)
* twtstr: fix startsWithIgnoreCasebptato2024-07-291-2/+2
|
* buffer, pager, config: add meta-refresh + misc fixesbptato2024-07-281-18/+12
| | | | | | | | | * buffer, pager, config: add meta-refresh value, which makes it possible to follow http-equiv=refresh META tags. * config: clean up redundant format mode parser * timeout: accept varargs for params to pass on to functions * pager: add "options" dict to JS gotoURL * twtstr: remove redundant startsWithNoCase
* url: misc fixes & improvementsbptato2024-07-241-25/+13
| | | | | | * fix various parsing bugs * rewrite state machine * other small optimizations
* html: event cleanup, XHR progressbptato2024-07-181-0/+27
|
* img, loader: separate out png codec into cgi, misc improvementsbptato2024-06-201-0/+3
| | | | | | | | | | | | | | | * multi-processed and sandboxed PNG decoding & encoding (through local CGI) * improved request body passing (including support for output id as response body) * simplified & faster blob()/text() - now every request starts suspended, and OngoingData.buf has been replaced with loader's buffering capability * image caching: we no longer pull bitmaps from the container after every single getLines call Next steps: replace our bespoke PNG decoder with something more usable, add other decoders, and make them stream.
* twtstr: fix overflow checkbptato2024-05-211-2/+2
|
* html: improve Request, derive Client from Windowbptato2024-05-201-8/+8
| | | | | | | * make Client an instance of Window (for less special casing) * misc work on Request & fetch * improve origin comparison (opaque origins of same URLs are now considered the same)
* luwrap: use separate context (+ various cleanups)bptato2024-05-101-137/+34
| | | | | | Use a LUContext to only load required CharRanges once per pager. Also, add kana & hangul vi word break categories for convenience.
* dom: simplify ButtonTypebptato2024-05-081-1/+1
|
* Remove unnecessary unsigned castsbptato2024-04-261-1/+1
| | | | | Unsigned operations and conversions to unsigned types always wrap/narrow without checks, so no need to manually mask/cast/etc. them.
* data: replace std/base64 with atobbptato2024-04-251-0/+63
| | | | | | | | | | std's version is known to be broken on versions we still support, and it makes no sense to use different decoders anyway. (This does introduce a bit of a dependency hell, because js/base64 depends on js/javascript which tries to bring in the entire QuickJS runtime. So we move that out into twtstr, and manually convert a Result[string, string] to DOMException in js/base64.)
* twtstr: remove pointless checks in parseIntImplbptato2024-04-191-5/+3
|