about summary refs log tree commit diff stats
path: root/src/local/container.nim
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* container: rename enumsbptato2024-03-271-17/+17
|
* buffer: fix cancel()bptato2024-03-271-10/+17
| | | | | | | | | | * 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
* io: derive DynStream from RootObj (not Stream)bptato2024-03-241-4/+4
| | | | | | | | 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.)
* buffer: send title during load + other title stuffbptato2024-03-211-12/+13
| | | | | | | * send title to pager as soon as it's available * expose `title' to DOM * rename undocumented `getTitle' js function to `title' getter in Container
* buffer: also buffer input readsbptato2024-03-211-3/+1
| | | | this is buffer reading from pager
* pager: add "save link", "save source"; change & document some keybindingsbptato2024-03-201-23/+43
| | | | | | | | | * `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
* buffer: add markURLbptato2024-03-191-2/+12
| | | | Useful when browsing plaintext files; w3m has it too.
* client: fix "Hit any key" bug on load failurebptato2024-03-171-5/+8
| | | | it's an unintended side effect that we do not want
* container: fall back to text/plain instead of application/octet-streambptato2024-03-161-1/+2
| | | | | | | | | | | | | This has its own problems, but application/octet-stream has the horrible consequence that opening any local file with an unrecognized type automatically quits the browser. (FWIW, w3m also falls back to text/plain, so it's not such an unreasonable default.) The proper solution would be to a) fix the bug that makes the browser auto-quit and b) show a "what to do" prompt for unrecognized file types (and allow users to override it, preferably on a per-protocol basis.)
* container: cursor x fixesbptato2024-03-151-2/+4
| | | | | | * also set fromX to corrected target x if target x is less than corrected x; this is mainly so that setCursorX(-1) works as expected * return w from cursorFirstX() even if cursorx is <= the last character
* Clean up BufferConfigbptato2024-03-151-11/+14
| | | | | | | | It was defined in the wrong module, and unnecessarily included LoaderClientConfig. Also, referrerPolicy was not being propagated to loader clients because it was (incorrectly) in BufferConfig instead of LoaderClientConfig.
* pager: unregister containers properly when headers are pendingbptato2024-03-141-1/+2
| | | | | It can happen that a container is deleted before it acquires a buffer process; add it to the `unreg' array in this case too.
* Move around some modulesbptato2024-03-141-1/+1
| | | | | | | | * extern -> gone, runproc absorbed by pager, others moved into io/ * display -> local/ (where else would we display?) * xhr -> html/ * move out WindowAttributes from term, so we don't depend on local from server
* pager: add "open in editor" keybinding (sE)bptato2024-03-141-2/+4
| | | | | | only for source for now, rendered document is a bit more complicated (also, get rid of useless extern/editor module)
* client: fix blocking reads on container connectionbptato2024-03-121-1/+0
| | | | | | | | | | | | | | | | Sometimes, headers take a while to reach us even after the result has been sent. e.g. echo 'Cha-Control: Connected' sleep 5 echo 'Cha-Control: ControlDone' ^ this froze the UI for 5 seconds, that's certainly not what we want. Since we don't have a proper buffered reader yet, and I don't want to write another disgusting hack like BufStream, we just use a state machine to figure out how much we can read. Sounds bad, but in practice it works just fine since loader's response patterns are very simple.
* loader: remove applyHeadersbptato2024-03-121-11/+8
| | | | | | | Better compute the values we need on-demand at the call sites; this way, we can pass through content type attributes to mailcap too. (Also, remove a bug where applyResponse was called twice.)
* posixstream: do not ignore lseek resultbptato2024-03-121-2/+6
|
* pager: do not eat error alerts on startupbptato2024-03-111-1/+0
| | | | | cetStatus is only called for soft status updates, not alerts (we have cetAlert for that)
* loader: rework process modelbptato2024-03-111-207/+176
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Originally we had several loader processes so that the loader did not need asynchronity for loading several buffers at once. Since then, the scope of what loader does has been reduced significantly, and with that loader has become mostly asynchronous. This patch finishes the above work as follows: * We only fork a single loader process for the browser. It is a waste of resources to do otherwise, and would have made future work on a download manager very difficult. * loader becomes (almost) fully async. Now the only sync part is a) processing commands and b) waiting for clients to consume responses. b) is a bit more problematic than a), but should not cause problems unless some other horrible bug exists in a client. (TODO: make it fully async.) This gives us a noticable improvement in CSS loading speed, since all resources can now be queried at once (even before the previous ones are connected). * Buffers now only get processes when the *connection* is finished. So headers, status code, etc. are handled by the client, and the buffer is forked when the loader starts streaming the response body. As a result, mailcap entries can simply dup2 the first UNIX domain socket connection as their stdin. This allows us to remove the ugly (and slow) `canredir' hack, which required us to send file handles on a tour accross the entire codebase. * The "cache" has been reworked somewhat: - Since canredir is gone, buffer-level requests usually start in a suspended state, and are explicitly resumed only after the client could decide whether it wants to cache the response. - Instead of a flag on Request and the URL as the cache key, we now use a global counter and the special `cache:' scheme. * misc fixes: referer_from is now actually respected by buffers (not just the pager), load info display should work slightly better, etc.
* buffer: improve/fix onload return valuesbptato2024-03-031-9/+14
| | | | | | | | | Only report when bytesRead has changed, otherwise we get unnecessary load requests. (This means -2 return value no longer exists; it did not work correctly anyway.) Also, fix the race condition that broke onload returns when onload happened before client requested load.
* container: fix off-by-one error in scrollDownbptato2024-03-021-1/+1
|
* container: fix cursorLineBegin/cursorLineTextStart with vertical scrollbptato2024-03-011-1/+3
| | | | | | setCursorX only moves the screen backwards if the intended X position is lower than the actual X position. Pass it -1 so that this is true even with zero-width lines.
* buffer, client: fix deadlock with send() callsbptato2024-02-291-6/+7
| | | | | | | | | | This is an ancient bug, but it got much easier to trigger with mouse scrolling support so it's time to fix it. (The bug itself was that since both the client and buffer ends of the controlling stream are blocking, they could get stuck when both were trying to send() data to the other end but the buffer was full. So now we set the client end to non-blocking.)
* Add mouse supportbptato2024-02-291-14/+20
|
* container: fix cursor positioning bugsbptato2024-02-281-6/+24
| | | | | | | | | * fix cursor jumping back to the start of the line (instead of the end of the line) when it is outside the viewport and a leftwards update is requested * save setxsave too when line is not loaded yet * always set needslines in onMatch when hlon (this was causing a blank screen when incremental search was jumping around in large documents)
* buffer: add image viewer supportbptato2024-02-271-24/+23
|
* misc refactoringsbptato2024-02-271-5/+5
| | | | | | * rename buffer enums * fix isAscii for char 0x80 * remove dead code from URL
* buffer: reset prevStyled in switchCharset, reshapebptato2024-02-271-9/+3
| | | | | | | | reshape must do a render from zero, as it's a last resort for users to fixup the page on a rendering bug. switchCharset must reset prevStyled for obvious reasons (it refers to a dead document).
* buffer: clean up onload, fix console updatebptato2024-02-261-40/+39
| | | | | | | | | | | | * reduce onload result size to a single int * clean up mess that was the container onload handler This fixes automatic refresh in console. Before, the client would only request a screen update after receiving the number of bytes read, but before the screen was actually reshaped (which obviously resulted in a race condition). Now, "I've reshaped the document" is a separate response (and is the only occasion where the screen is updated before the final render).
* term: improve pixels-per-column/line detectionbptato2024-02-251-1/+1
| | | | | | | | | Some terminal emulators (AKA vte) refuse to set ws_xpixel and ws_ypixel in the TIOCGWINSZ ioctl, so we now query for CSI 14 t as well. (Also CSI 18 t for good measure, just in case we can't ioctl for some reason.) Also added some fallback (optionally forced) config values for width, height, ppc, and ppl. (This is especially useful in dump mode.)
* buffer: remove BufferSourcebptato2024-02-221-20/+18
| | | | | | | | | | Aside from being a wrapper of Request, it was just storing the -I charset, except even that didn't actually work. Whoops. This fixes -I effectively not doing anything; now it's a forced override that even disables BOM sniffing. (If the user wants to decode a file using a certain encoding, it seems wise to assume that they really meant it.)
* buffer: clean up contentTypebptato2024-02-221-15/+19
| | | | | | | | | | This fixes a bug where setContentType would call setHTML twice, which messed up charsets and probably a couple more things. As a bonus, it allows us to pass around the content type less. In fact, buffer does not have to know its exact content type, just whether it is in HTML mode or not. So that's all we tell it now; only container still keeps track of the content type (as it should).
* Replace Chakasu with Chagashibptato2024-02-221-1/+1
| | | | | | The API is horrid :( but at least it copies less. TODO: think of a better API.
* container: fix crash on clone -> view sourcebptato2024-02-191-5/+9
| | | | | * set loaderPid in clones too * handle URL in container the same way as in buffer
* winattrs: remove unnecessary call, fix height_px fallbackbptato2024-02-171-3/+2
| | | | no need for every new buffer to query the window size
* layout: use html/body bgcolor as canvas bgcolorbptato2024-02-171-7/+20
| | | | | | This is required by the standard. (Without this, lots of websites have incorrect background colors, because they set the body height to 100% of the viewport.)
* container: set color on double width char + tab fillersbptato2024-02-161-7/+10
|
* Various refactorings & fixesbptato2024-02-141-1/+0
| | | | | | | | * disallow Stream interface usage on non-blocking PosixStreams * do not read estream of forkserver byte-by-byte (it's slow) * do not call writeData with a zero len in formdata * do not quote numbers in mailcap quoteFile * remove some unused stuff
* pager: reduce boilerplatebptato2024-02-141-2/+2
| | | | also spawn less processes in some cases
* container: allow dismissing loadinfobptato2024-02-131-6/+12
| | | | it broke line info in console since it's never fully loaded
* container: do not reshape twice on loading documentsbptato2024-02-121-18/+18
|
* buffersource: remove location fieldbptato2024-02-121-9/+12
|
* Add pager.externFilterSourcebptato2024-02-121-0/+4
| | | | useful for filtering stuff through commands like rdrview
* Remove CLONE BufferSource; cache document sources in tmpdirbptato2024-02-121-9/+28
| | | | | | | | | | | | | | | | | | | | | | | At last all BufferSources are unified. To achieve the same effect as the previous CLONE source type, we now use the "fromcache" flag in Request. This *forces* the document to be streamed from the disk; if the file no longer exists for some reason, an error is returned (i.e. the document is not re-downloaded). For a document to be cached, it has to be the main document of the buffer (i.e. no additional resources requested with fetch()), and also not an x-htmloutput HTML file (for those, the original source is saved). The result is that toggleSource now always returns the actual source for e.g. markdown files, not the HTML-transformed version. Also, it is now possible to view the source of a document that is still being downloaded. buffer.sstream has almost been eliminated; it still exists, but only as a pseudo-buffer to interface with EncoderStream and DecoderStream. It no longer holds the entire source of a buffer at any point, and is cleared as soon as the buffer is completely loaded.