about summary refs log tree commit diff stats
path: root/src/local
Commit message (Collapse)AuthorAgeFilesLines
...
* client, pager: remove unnecessary std/streamsbptato2024-05-112-12/+7
|
* buffer: fix multipart formsbptato2024-05-113-23/+46
| | | | | | | | | * 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
* pager: take $EDITOR from envbptato2024-05-111-5/+5
| | | | | | * use EDITOR environment variable in default config, fix line number ordering in fallback * autodetect vi-like editors and add line number
* term: optimize canvas redraw, remove emulate-overlinebptato2024-05-101-63/+38
| | | | | | | * Replaced the `pcanvas' comparison with a much simpler tracking of the first damaged cell in writeGrid, which is significantly faster. * Removed emulate-overline: it's of too little utility compared to the maintenance burden it caused.
* luwrap: use separate context (+ various cleanups)bptato2024-05-103-64/+55
| | | | | | 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-092-2/+5
| | | | | | | | | | | | | | | | | 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-084-10/+15
| | | | | | | * prefix to-be-separated modules with js * remove dynstreams dependency * untangle from EmptyPromise * move typeptr into tojs
* js: fix compilation on 1.6.14bptato2024-05-061-1/+1
| | | | | | | | | * resolve empty promises without params, not a single undefined param (we can't just unsafeAddr constants on 1.6.14, and I don't see why we need to pass undefined?) * same in client with InternalError * explicitly convert static `asglobal' to bool (1.6.14 turns unquoted enums into ints...)
* Use isSome instead of isOkbptato2024-05-053-5/+5
| | | | no point in having identical overloads
* client: make quit() actually quit, misc fixesbptato2024-05-042-34/+43
| | | | | | | * unwind the QJS stack with an uncatchable exception when quit is called * clean up JS references in JSRuntime free even when the Nim counterparts are still alive * simplify some tests
* js: fix various leaks etc.bptato2024-05-032-48/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously we didn't actually free the main JS runtime, probably because you can't do this without first waiting for JS to unwind the stack. (This has the unfortunate effect that code now *can* run after quit(). TODO: find a fix for this.) This isn't a huge problem per se, we only have one of these and the OS can clean it up. However, it also disabled the JS_FreeRuntime leak check, which resulted in sieve-like behavior (manual refcounting is a pain). So now we choose the other tradeoff: quit no longer runs exitnow, but it waits for the event loop to run to the end and only then exits the browser. Then, before exit we free the JS context & runtime, and also all JS values allocated by config. Fixes: * fix `ad' flag not being set for just one siteconf/omnirule * fix various leaks (since leak check is enabled now) * use ptr UncheckedArray[JSValue] for QJS bindings that take an array * allow JSAtom in jsgetprop etc., also disallow int types other than uint32 * do not set a destructor for globals
* loader: fix applying config for initial requestbptato2024-05-021-2/+1
| | | | | | Instead of the error-prone method of selectively applying config values only for non-initial requests, add a separate (privileged) loader command which allows specifying a different client config.
* config: add insecure-ssl-no-verify option to siteconfbptato2024-05-011-1/+5
| | | | | | | Equivalent to curl --insecure. Note: unfortunately this does not help if the server is using unsafe legacy renegotiation, you have to allow that in the OpenSSL config.
* term: fix incorrect dimensions used in sixelbptato2024-04-291-30/+29
|
* term: add sixel background color blendingbptato2024-04-291-9/+19
| | | | | | | | | | | | | * blend bgcolor with cell color * do not round up to 6 We don't use the sixel transparency feature because it's useless: sixel transparency (AFAICT) only lets us respect alpha == 0, but we should either respect *all* alpha, or no alpha at all. Since we do color blending, we *do* respect all alpha, but only of background color. This sadly means that text under images gets destroyed, but at least transparent images don't look like garbage.
* term: remove background color blending in sixelbptato2024-04-271-9/+1
|
* ua.css: style xmp like prebptato2024-04-271-1/+9
|
* buffer: add toggleImagesbptato2024-04-271-0/+9
|
* term: query sixel color register numberbptato2024-04-271-32/+51
|
* Remove unnecessary unsigned castsbptato2024-04-261-2/+2
| | | | | Unsigned operations and conversions to unsigned types always wrap/narrow without checks, so no need to manually mask/cast/etc. them.
* pager: reduce unnecessary image redrawsbptato2024-04-261-1/+1
| | | | the status line can't have images, so this should work
* term: add sixel encoderbptato2024-04-251-84/+179
|
* Initial image supportbptato2024-04-253-16/+95
| | | | | | | | | | | | | | | | | * 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-183-6/+26
| | | | | | | | | | | | | | | | | 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-176-203/+207
| | | | | | * separate params with ; (semicolon) instead of , (colon) * reduce screaming snake case use * wrap long lines
* term: save/restore title after "set title"bptato2024-04-161-2/+12
| | | | | | | | | It is quite straightforward, because XTerm has a functionality to do just this. (In fact, it automatically restores the title when I use smcup/rmcup. But when I don't, it will linger until I close the window or change the title again.)
* js: remove automatic function -> closure conversionbptato2024-04-151-14/+28
| | | | | | | | | | | | | | | It's a bad idea for several reasons: * it's inefficient; must allocate an environment for a closure in Nim, even though we already have one in JS * writing macros for automatically creating functions with variadic arguments is suprisingly difficult (see the entire `js/javascript' module) * it never really worked properly, because we never freed the associated function pointer. We hardly used it anyway, so the easiest fix is to get rid of it completely.
* term: do not eat last DA1 valuebptato2024-04-101-3/+9
|
* pager: fix incremental search with empty stringbptato2024-03-301-3/+11
| | | | | | | | | | | | | | This is broken in w3m too, so we take nvi behavior instead. Also, we now consistently complain when the user tries to search for an empty string instead of just occasionally spitting out "invalid regex" alerts. (In w3m, /search^M/^M just jumps to the first search result with ISEARCH. In nvi, it jumps to the second one with both searchincr on and off. w3m only produces the latter behavior with regular search, which is I assume why I made it work this way, but it's still inconsistent for no good reason.)
* 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-302-1/+9
|
* pager: edit source fixesbptato2024-03-301-27/+8
| | | | | | | * URI-decode path name for local files in default config * (ab)use mailcap command quoting for passing params to editor command instead of replicating it badly in formatEditorName * rename mailcap enums
* term: flush stdout in anyKeybptato2024-03-291-0/+1
|
* pager: fix broken writeToFilebptato2024-03-291-5/+1
|
* fflush() before forksbptato2024-03-281-6/+11
| | | | | seems like a good idea, especially because CGI uses stdout as the IPC mechanism
* Add capsicum supportbptato2024-03-281-2/+5
| | | | | | | | | | | | | It's the sandboxing system of FreeBSD. Quite pleasant to work with. (Just trying to figure out the basics with this one before tackling the abomination that is seccomp.) Indeed, the only non-trivial part was getting newSelector to work with Capsicum. Long story short it doesn't, so we use an ugly pointer cast + assignment. But even that is stdlib's "fault", not Capsicum's. This also gets rid of that ugly SocketPath global.
* term: improve color detectionbptato2024-03-271-5/+16
| | | | | some terminals (alacritty) don't support XTGETTCAP and don't even respond with ANSI color support to DA1, so just fall back to termcap.
* container: rename enumsbptato2024-03-271-17/+17
|
* buffer: fix cancel()bptato2024-03-272-11/+33
| | | | | | | | | | * fix mismatch between return value & read value that would either crash or freeze the browser depending on its mood * add an assertion to detect the above footgun * fix some resource leaks * fix iteration over a table that called a function which altered the table in buffer's cancel() * if user cancels before anything is loaded, destroy the container too
* config: improve input systembptato2024-03-261-8/+10
| | | | as described in <https://todo.sr.ht/~bptato/chawan/6>
* config, toml: rename enumsbptato2024-03-261-13/+13
|
* pager: percent-decode path name in askDownloadPathbptato2024-03-251-1/+1
|
* client, forkserver: remove useless codebptato2024-03-241-1/+0
|
* js: proper distinction between Opt/Optionbptato2024-03-241-6/+6
| | | | | | | | | | | | | | | | until now, this had very strange (and inconsistent) semantics: * err() was used for exception propagation, but also as a null value * Option accepted undefined as a none value, but not null * Opt and Option were used interchangeably (and mostly randomly) Now, Result is always used for error reporting, and err(nil) means JS_EXCEPTION. (Opt is a special case of Result where we don't care about the error type, and is not used in JS.) Option on the other hand means "nullable variation of normally non-nullable type", and translates to JS_NULL. In JS we mainly use it for turning strings nullable.
* buffer: fix clonebptato2024-03-241-3/+3
|
* io: derive DynStream from RootObj (not Stream)bptato2024-03-243-55/+62
| | | | | | | | This way they are no longer compatible, but we no longer need them to be compatible anyway. (This also forces us to throw out the old serialize module, and use packet writers everywhere.)
* pager: detect JS as textbptato2024-03-241-1/+5
| | | | | hack so it's possible to view JS code in a buffer even if it's set as e.g. application/javascript in user mime.types
* io: add bufreaderbptato2024-03-211-1/+1
| | | | analogous to bufwriter
* config: add default-headers to siteconfbptato2024-03-211-19/+7
| | | | | | | So long as we have to live with siteconf, let's at least make it useful. Also, rewrite the header overriding logic because while it did work, it only did so accidentally.
* term: use termcap for italic resetbptato2024-03-211-3/+7
|