about summary refs log tree commit diff stats
path: root/src/local/container.nim
Commit message (Collapse)AuthorAgeFilesLines
* sixel, term: reduce half-dump special casingbptato2024-10-041-0/+2
| | | | | | | Makes it slightly easier to debug image output. Also, we stop sending dimension headers, and no longer check for the scheme env var to make CLI invocation a bit less annoying.
* container: fix control char displaybptato2024-09-281-20/+15
| | | | | | Also, kill twidth and its friends; we haven't been using it for a while now. (In the future, a solution with PUA chars might be worth exploring.)
* container: don't show hover type on ubptato2024-09-271-1/+1
| | | | it's a waste of space, and doesn't work well with showFullAlert
* sixel: support transparencybptato2024-09-241-0/+2
| | | | | | | | | | | | | | | | | | Sixel can only represent transparency for fully transparent (alpha = 0) and fully opaque (alpha = 255) pixels, i.e. we would have to do blending ourselves to do this "properly". But what do you even blend? Background color? Images? Clearly you can't do text... So instead of going down the blending route, we now just approximate the 8-bit channel with Sixel's 1-bit channel and then patch it up with dither. It does look a bit weird, but it's not *that* bad, especially compared to the previous strategy of "blend with some color which hopefully happens to be the background color" (it rarely was). Note that this requires us to handle transparent images specially in term. That is, for opaque ones, we can leave out the "clear cells affected by image" part, but for transparent ones, we must clear the entire image every time.
* select: use a separate module (again)bptato2024-09-241-350/+52
| | | | | | | | | Now we dispatch to select objects from the pager object too, just to make things even more confusing. Well, it works better than the previous arrangement, in that trying to use unimplemented movements now just throws instead of moving around the container. Yay for OOP (?)
* pager: fix double-width overprint & reload blank screen bugbptato2024-09-241-5/+10
| | | | | * fix overprint of double width chars in status & select * fix blank screen on reload + startpos screen move
* loader: mmap intermediate image files, misc refactoringbptato2024-09-221-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | * refactor parseHeader * optimize response blob() * add direct "to cache" mode for loader requests which sets stdout to a file, and use it for image processing * move image resizing into a separate process * mmap cache files in between processing steps when possible At last, resize is no longer a part of image decoding. Also, it feels much nicer to keep encoded image data in the same cache as everything else. The mmap operations *should* be more efficient than copying the whole RGBA data through a pipe. In practice, it only makes a difference for loading (well, now just mmapping) the encoded image into the pager, where it singlehandedly speeds up image display by 10x on my test image. For the other steps, the unfortunate fact that "tocache" must delay the next fork/exec in the pipeline until the entire image is processed seems to equal out any wins we might have gotten from skipping a single raw RGBA copy. I have tried moving the delay before the exec (it's possible with yet another pipe), but it didn't help much and made the code much uglier. (Not that tocache didn't, but I can live with this...)
* pager: improve hover text handlingbptato2024-09-221-1/+2
| | | | | | | | | | | * align status truncating behavior with w3m (not exactly, clipping is still different, but this should be fine for now) * add "su" for "show last alert" - w3m's solution here is to scroll one char at a time with "u", but that's extremely annoying to use. We already have a line editor that can navigate lines, so reuse that instead. * fix peekCursor showing empty text * update todo
* loader: refactor/move around some procsbptato2024-09-151-2/+3
| | | | | | | | | | | | | | Module boundaries didn't make much sense here either. Specifically: * loader/cgi was originally just one of the many "real" protocols supported by loader, so it was in a separate module (like the other ones). Now it's mostly an "internal" protocol, and it was getting cumbersome to pass all required loader state to loadCGI. * The loader interface has grown quite large, but there is no need for (or advantage in) putting it in the same module as the implementation. Now CGI is handled by loader, and the interface is in the new module "loaderiface".
* Refactor img/*bptato2024-09-151-1/+1
| | | | | I've moved most image logic to adapter, so it doesn't really make sense to have this subdir anymore.
* loader: refactor, misc optimizations & fixesbptato2024-09-141-1/+5
| | | | | | | | * factor out input/output handle tables; use a seq instead * add possibility to directly open cached items onto stdin (mainly an optimization for reading images, which are always cached) * close used handles on local CGI execution * make clone during load work again
* pager: fix saveSourcebptato2024-09-101-1/+3
| | | | | | Welp. The fence was needed after all. The keybinding was broken anyway; fix that too.
* pager: fix rewrite-url weirdnessbptato2024-09-101-3/+1
| | | | | | | | | saveSource's URL overriding mechanism conflicted with rewrite-url, since the latter wouldn't change the overriding URL (which was not optional either). Remove the former since a) it's just cosmetic and b) not really visible to the user at all.
* utils: add twtunibptato2024-09-081-101/+104
| | | | | | | | | | | | | | | | | | | 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.
* canvas: move to separate CGI scriptbptato2024-09-011-1/+1
| | | | | | | | | | * stream: and passFd is now client-based, and accessible for buffers * Bitmap's width & height is now int, not uint64 * no more non-network Bitmap special case in the pager for canvas I just shoehorned it into the static image model, so it still doesn't render changes after page load. But at least now it doesn't crash the browser.
* sixel: break out into a separate cgi scriptbptato2024-08-241-2/+14
| | | | | | | | This caches sixel output. Works best when the line height is a multiple of 6px, but should still be faster than the previous solution everywhere else too (simply by virtue of encoding separate images in parallel). Next step: actual color quantization
* winattrs: un-snakeifybptato2024-08-231-1/+1
|
* dom, xhr: slight progress on modules, fix an XHR bugbptato2024-08-151-6/+1
| | | | | | * actually download & compile modules (but don't run them yet) * fix a bug in XHR (on some older Nim versions, move() doesn't actually move)
* dom: remove generic JS bindingsbptato2024-08-111-19/+19
| | | | Dispatch manually with fromJS instead.
* pager: fix <select> drawing after container redrawbptato2024-08-091-1/+1
|
* Update monouchabptato2024-08-091-1/+1
|
* Fixes for Nim 2.2bptato2024-07-291-2/+0
| | | | | | | | | * xmlhttprequest: fix missing import * painter: generic tuple workaround * dynstream: merge module with implementations (so it will work with vtables) Not enabling vtables yet since it doesn't work with refc.
* buffer, pager, config: add meta-refresh + misc fixesbptato2024-07-281-2/+16
| | | | | | | | | * 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
* pager: fix dead containers left in replaceBackupbptato2024-07-231-0/+3
| | | | | | | | | | | fixes the following bug: * click a link that redirects somewhere * go back * discard buffer (that had the link) * discard the new buffer then you would find yourself in a zombie buffer you previously discarded
* loader: copy cached items on buffer cloningbptato2024-07-201-0/+3
| | | | | This fixes a bug where cloning buffers with images would crash the browser.
* pager: fix redirection to deleted buffersbptato2024-07-061-0/+1
| | | | | | Fixes the bug where getting redirected to a buffer that the pager then deleted (e.g. image display, site no longer available, etc.) would land you in a buffer detached from the main tree.
* pager: PNGify kitty images, clear images on buffer switchbptato2024-07-021-0/+2
| | | | | | | | | | | Saves bandwidth; it's especially useful over SSH. Still not sure if this is the right solution, since it now needs two select cycles instead of one, and it does yet another copy of the image. (Unnecessarily, because stbi cannot stream its output, and stbiw cannot stream its input.) Also, to save memory, we now discard decoded images of buffers that are not being viewed.
* promise, container: fix nil derefsbptato2024-06-301-1/+3
|
* dom, pager: cache images from networkbptato2024-06-291-4/+8
| | | | | | | | | | | With many limitations: * slightly randomized expiry, so it's harder to fingerprint * only images. so e.g. CSS is still left uncached * it's per-buffer and non-persistent, so images are still redownloaded for every new page load so it's more of an image sharing between placements than true caching.
* misc cleanupsbptato2024-06-221-2/+1
|
* pager: refactor drawing codebptato2024-06-221-50/+344
| | | | | | | * merge select into container * avoid unnecessary redraws in draw() for parts of the screen that haven't been updated * various image redraw fixes
* term, pager: improve image displaybptato2024-06-211-5/+9
| | | | | | * basic repaint algorithm for sixel (instead of brute force "clear the whole screen") * do not re-send kitty images already on the screen
* client, pager: fix cached item refcounting bugsbptato2024-06-211-3/+1
|
* img, loader: separate out png codec into cgi, misc improvementsbptato2024-06-201-0/+8
| | | | | | | | | | | | | | | * 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.
* buffer: add autofocusbptato2024-06-081-22/+25
| | | | naturally, it's opt-in
* pager, buffer: improve forms, protocol configbptato2024-06-081-4/+4
| | | | | | * refactor form submission * add options to specify form handling per protocol * block cross-protocol POST requests
* Move JS wrapper into Monouchabptato2024-06-031-3/+5
| | | | Operation "modularize Chawan somewhat" part 3
* html: improve Request, derive Client from Windowbptato2024-05-201-2/+2
| | | | | | | * 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)
* container: remove unused codebptato2024-05-121-5/+0
|
* buffer: fix multipart formsbptato2024-05-111-17/+23
| | | | | | | | | * fix enctype not getting picked up * fix form data constructor requiring open() syscall (which gets blocked by our seccomp filter) * add closing boundary to multipart end * pass fds instead of path names through WebFile/Blob and send those through bufwriter/bufreader
* luwrap: use separate context (+ various cleanups)bptato2024-05-101-57/+41
| | | | | | 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-2/+4
| | | | | | | | | | | | | | | | | 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.
* js: refactorbptato2024-05-081-1/+1
| | | | | | | * prefix to-be-separated modules with js * remove dynstreams dependency * untangle from EmptyPromise * move typeptr into tojs
* Use isSome instead of isOkbptato2024-05-051-1/+1
| | | | no point in having identical overloads
* buffer: add toggleImagesbptato2024-04-271-0/+9
|
* Initial image supportbptato2024-04-251-4/+5
| | | | | | | | | | | | | | | | | * png: add missing filters, various decoder fixes * term: fix kitty response interpretation, add support for kitty image detection * buffer, pager: initial image display support Emphasis on "initial"; it only "works" with kitty output and PNG input. Also, it's excruciatingly slow, and repaints images way too often. Left undocumented intentionally it for now, until it actually becomes useful. In the meantime, adventurous users can find out themselves why: [[siteconf]] url = "https://.*" images = true
* sandbox: seccomp support on Linuxbptato2024-04-181-5/+21
| | | | | | | | | | | | | | | | | We use libseccomp, which is now a semi-mandatory dependency on Linux. (You can still build without it, but only if you pass a scary long flag to make.) For this to work I had to disable getTimezoneOffset, which would otherwise call localtime_r which in turn reads in some files from /usr/share/zoneinfo. To allow this we would have to give unrestricted openat(2) access to buffer processes, which is unacceptable. (Giving websites access to the local timezone is a fingerprinting vector so if this ever gets fixed then it should be an opt-in config setting.) This patch also includes misc fixes to buffer cloning, and fixes the LIBEXECDIR override in the makefile so that it is actually useful.
* Update code stylebptato2024-04-171-89/+92
| | | | | | * separate params with ; (semicolon) instead of , (colon) * reduce screaming snake case use * wrap long lines
* pager: fix weird halfPage* behaviorbptato2024-03-301-6/+6
| | | | | | | | | For some reason, halfPageDown decremented height instead of incrementing it, which caused some rather weird behavior where halfPageUp + halfPageDown would put the cursor in a different position than it was before. Also, we must increment *before* dividing to mimic vi behavior properly.
* pager: exclude status line from buffer heightbptato2024-03-301-0/+4
|