about summary refs log tree commit diff stats
path: root/src/utils
Commit message (Collapse)AuthorAgeFilesLines
* Eliminate some superfluous copiesbptato2025-05-113-9/+9
|
* 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
|
* myaddr: fix newSeqUninit polyfillbptato2025-05-011-1/+1
| | | | | | Sometimes it's called with an unsigned len. ref. https://todo.sr.ht/~bptato/chawan/59
* myaddr: backport & switch to newSeqUninitbptato2025-04-302-10/+15
|
* 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.
* Update libregexp/libunicode bindingsbptato2025-03-201-2/+2
| | | | Lack of cbool is a pain. I'm sticking with JS_BOOL for now.
* twtstr: normalize char constantsbptato2025-03-131-7/+7
|
* layout: skip Cf charactersbptato2025-02-151-0/+5
| | | | We cannot handle these yet.
* eprint: add fprintf wrapperbptato2025-01-311-0/+3
| | | | useful in situations where allocations change program behavior
* sandbox: fix compilation without sandboxingbptato2025-01-281-1/+1
|
* 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.)
* widthconv: fix hiragana -> half-width kana conversionbptato2025-01-151-0/+1
| | | | Unicode has no half-width hiragana :/
* 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.)
* Fix some strict defsbptato2025-01-121-2/+2
|
* buffer: remove server socketbptato2025-01-091-18/+14
| | | | | | | | | | | Now we just pass through a socket created in pager. This removes the need for a socket directory, and strengthens the buffer sandbox slightly. I've kept the ServerSocket code, because I want to add some form of RPC and communication between separate instances in the future. However, I don't expect this to be handled outside the main process, so I've removed the Capsicum-specific connectat/bindat code.
* twtstr: optimize a bitbptato2025-01-031-23/+19
|
* layout: ignore general category Me, Mnbptato2025-01-021-0/+10
| | | | | | | | | | I'm not sure if this is the best way. On one hand, it probably breaks text in some languages that cannot be represented in normal form. On the other hand, some terminals may crash on such strange sequences (or worse). I'll just skip them for now, because it's marginally faster than returning 0 from width. We'll see if somebody complains.
* Misc character display fixesbptato2024-12-224-45/+23
| | | | | | | | | | | | | | | | | | * 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
* nanosvg, myaddr: fix obuf type and myaddr shimbptato2024-12-201-2/+2
| | | | | | | this is exactly why I shimmed in unsafeAddr, but the compiler isn't cooperating... :( well, it seems to work with auto.
* default(T) -> T.default, add some strict defsbptato2024-12-172-3/+4
|
* 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
|
* Fix casingbptato2024-12-051-1/+1
|
* mimetypes: refactor, use mime.types for inline image extensionsbptato2024-12-052-46/+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
* chaseccomp: update docs, remove redundant importbptato2024-11-071-2/+0
|
* luwrap: fix compilation on 2.0.8 and refactor a bitbptato2024-11-053-9/+11
| | | | ref. https://todo.sr.ht/~bptato/chawan/21
* utils, types: merge some modulesbptato2024-11-038-116/+113
| | | | | * line, vector, matrix -> path * twtuni, charcategory -> twtstr
* chaseccomp: fix compilation with newest dash, misc changesbptato2024-10-311-3/+0
| | | | | | | | | | | | | | * fix matching on unstripped whitespace: caught after upgrading to upstream dash & chaseccomp wouldn't compile * add defines to ensure that we computed the filter length correctly * inline cut_label * EPERM on sigaction, sigprocmask, gettid, and kill on tgkill (so a crash doesn't trigger sandbox violations) * move SIGSYS handler to C and add one for the network The last change removes the stack trace from SIGSYS, but gives us the syscall number which is probably more useful. (Indeed, we don't even have a stack trace in release builds.)
* 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.)
* sandbox: use relative path to the object filebptato2024-10-231-1/+6
|
* sandbox: replace libseccomp with chaseccompbptato2024-10-231-176/+29
| | | | | | | | | | | | | | | This drops libseccomp as a dependency. Also, move the capsicum/pledge definitions from bindings to sandbox.nim because they are only used there. Interestingly, after integrating chaseccomp I found that the stbi process would mysteriously crash by a getrandom(2) syscall. Closer investigation revealed it is only called on the initialization of glibc's malloc; presumably it had never surfaced before because libseccomp would always allocate before entering the sandbox. So I've added getrandom to our filter as well.
* dynstream, serversocket: use posix instead of nativesocketsbptato2024-10-201-3/+3
| | | | | | | | | | | nativesockets is a wrapper over posix and winapi, but we don't support winapi, so we can just fall back to PosixStream instead. SocketStream remains as a constraint over PosixStream to allow sendFileHandle/recvFileHandle. As a nice side effect, we can drop some allowed syscalls from the seccomp filter.
* sandbox: do not ask for signal permissionsbptato2024-10-171-3/+0
| | | | | On a second thought, no timeouts for name resolution is fine - and even if it weren't, it's better implemented in the loader.
* 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
|
* layout, pager: preserve tabs on display, selection & outputbptato2024-10-101-0/+43
| | | | | | | | | | | | Substitute tabs with one of eight PUA characters based on their width, and convert them back in the pager: * TUI mode always prints spaces, but now handles tabs appropriately on cursor movement * dump mode tries to preserve hard tabs, but uses soft tabs when that is not possible (e.g. tabs after a margin, tab with background color, etc) * selection mode always outputs hard tabs.
* twtstr: fix stripAndCollapsebptato2024-10-081-11/+9
|
* twtstr: misc refactoringsbptato2024-10-011-3/+3
|
* sandbox: allow clock_gettime64bptato2024-09-301-1/+2
| | | | used on 32-bit platforms
* Update monouchabptato2024-09-291-0/+1
| | | | | Now we use QuickJS-NG, which is better maintained than QJS and has column tracking.