about summary refs log tree commit diff stats
path: root/src/local/pager.nim
Commit message (Collapse)AuthorAgeFilesLines
...
* term, pager: improve image displaybptato2024-06-211-33/+71
| | | | | | * 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-6/+16
|
* img, loader: separate out png codec into cgi, misc improvementsbptato2024-06-201-6/+34
| | | | | | | | | | | | | | | * 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.
* pager: prefill lmUsername with current usernamebptato2024-06-161-1/+1
|
* pager: actually fix broken logicbptato2024-06-091-2/+2
| | | | | | | | ok we block if: * method is not GET * scheme is different * it is not the case that both the current and the target schemes are http/s
* pager: fix broken logicbptato2024-06-091-3/+3
| | | | bleh
* pager: send Accept: */* for viewImagebptato2024-06-081-2/+7
|
* buffer: add autofocusbptato2024-06-081-41/+35
| | | | naturally, it's opt-in
* pager, buffer: improve forms, protocol configbptato2024-06-081-13/+19
| | | | | | * refactor form submission * add options to specify form handling per protocol * block cross-protocol POST requests
* Move JS wrapper into Monouchabptato2024-06-031-9/+10
| | | | Operation "modularize Chawan somewhat" part 3
* pager: rework D/discard bufferbptato2024-05-311-47/+126
| | | | | | | | | | | | | | | | | | | | | The previous solution had the issue that it switched between "delete buffer, then move back" and "delete buffer, then move forward" depending on whether the buffer was the root of the buffer tree, which made its behavior quite unpredictable. Now the pager (sort of) remembers the direction you are coming from, and D moves in that direction. So e.g.: * Enter, D just moves back to where you were coming from (as before) * Comma, D deletes the previous buffer, then returns to the current buffer If no buffer exists in the target direction, then we alert. Also, new commands are: `d,' `d.'. They do the same thing the non-d-prefixed variations do, but also delete the current buffer. Useful if you're no longer sure where you are coming from, but know where you want to go. (`d,' in particular is equivalent to w3m's `B'.)
* html: improve Request, derive Client from Windowbptato2024-05-201-1/+1
| | | | | | | * 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)
* pager: editor command fixesbptato2024-05-121-2/+2
|
* client, pager: remove unnecessary std/streamsbptato2024-05-111-9/+6
|
* buffer: fix multipart formsbptato2024-05-111-1/+17
| | | | | | | | | * 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
* luwrap: use separate context (+ various cleanups)bptato2024-05-101-3/+7
| | | | | | Use a LUContext to only load required CharRanges once per pager. Also, add kana & hangul vi word break categories for convenience.
* js: refactorbptato2024-05-081-2/+2
| | | | | | | * prefix to-be-separated modules with js * remove dynstreams dependency * untangle from EmptyPromise * move typeptr into tojs
* Use isSome instead of isOkbptato2024-05-051-3/+3
| | | | no point in having identical overloads
* client: make quit() actually quit, misc fixesbptato2024-05-041-1/+1
| | | | | | | * 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-031-16/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* pager: reduce unnecessary image redrawsbptato2024-04-261-1/+1
| | | | the status line can't have images, so this should work
* Initial image supportbptato2024-04-251-0/+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-1/+1
| | | | | | | | | | | | | | | | | 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-44/+46
| | | | | | * separate params with ; (semicolon) instead of , (colon) * reduce screaming snake case use * wrap long lines
* 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.
* 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: exclude status line from buffer heightbptato2024-03-301-1/+5
|
* 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
* 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
* buffer: fix cancel()bptato2024-03-271-1/+16
| | | | | | | | | | * 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
* pager: percent-decode path name in askDownloadPathbptato2024-03-251-1/+1
|
* 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.
* io: derive DynStream from RootObj (not Stream)bptato2024-03-241-25/+29
| | | | | | | | 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
* 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.
* libregexp: update LRE_FLAG_UTF16 namebptato2024-03-211-1/+1
| | | | upstream now calls it unicode
* cell: update FormatFlag naming, remove useless templatesbptato2024-03-211-1/+1
|
* pager: fix flipped predicate for downloadbptato2024-03-211-1/+1
| | | | we want to check if it's *not* text.
* pager: add "save link", "save source"; change & document some keybindingsbptato2024-03-201-38/+66
| | | | | | | | | * `s{Enter}' now saves link, and `sS' saves source. * Changed ;, +, @ to g0, g$, gc so that it's somewhat consistent with vim (and won't conflict with ; for "repeat jump to char") * Changed (, ) to -, + so that it doesn't conflict with vi's "previous/next sentence" (once we have it...) * Add previously missing keybindings to about:chawan
* pager: do not ask to download text/*bptato2024-03-191-1/+1
| | | | it's text, so we can display it anyway.
* buffer: add markURLbptato2024-03-191-1/+2
| | | | Useful when browsing plaintext files; w3m has it too.
* client: refactor inputbptato2024-03-181-9/+7
| | | | | * move mouse handling to term * do not use File for input just to disable buffering anyway
* config: parse mime.types/mailcap/urimethodmap inside parseConfigbptato2024-03-181-17/+8
| | | | | | Better (and simpler) than storing them all over the place. extra: change lmDownload text to match w3m
* pager: remove useless codebptato2024-03-181-15/+0
|
* config: clean up/simplifybptato2024-03-171-20/+6
| | | | | | | | | * Parse the default config at runtime. There's no significant performance difference, but this makes it much less painful to write config code. * Add better error reporting * Make fromJS2 easier to use * Unquote ChaPaths while parsing config
* client: fix "Hit any key" bug on load failurebptato2024-03-171-11/+21
| | | | it's an unintended side effect that we do not want