about summary refs log tree commit diff stats
path: root/src/local
Commit message (Collapse)AuthorAgeFilesLines
* pager: remove useless codebptato2024-03-182-16/+1
|
* config: clean up/simplifybptato2024-03-172-26/+14
| | | | | | | | | * 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-173-21/+45
| | | | it's an unintended side effect that we do not want
* pager: fix buffer filteringbptato2024-03-171-2/+4
|
* io: add BuferedWriterbptato2024-03-161-2/+3
| | | | | | | | | | Unsurprisingly enough, calling `write` a million times is never going to be very fast. BufferedWriter basically does the same thing as serialize.swrite did, but queues up writes in batches before sending them. TODO: give sread a similar treatment
* client, pager: various file saving fixesbptato2024-03-163-18/+22
| | | | | | * do not immediately quit when all containers are gone * fix double saving bug * fix wrong "save to" string
* pager: fix disappearing buffers when reload failsbptato2024-03-161-9/+8
| | | | | we do have logic for this in replace(), but it was not working because setContainer changed the buffer too early.
* 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.)
* pager: simplify line editingbptato2024-03-162-64/+69
| | | | | * embed prompt string into enums * move pager.username to LineDataAuth
* pager, loader: add "Save file to" functionalitybptato2024-03-161-11/+74
| | | | | | | As simple as it could be; no download panel yet. Also, remove the xdg-open default mailcap entry; it's better to just save by default.
* config: add start.console-buffer optionbptato2024-03-162-3/+4
| | | | useful for debugging
* 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-153-36/+61
| | | | | | | | 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.
* client: check if container was found before deleting itbptato2024-03-141-2/+2
| | | | | | Containers may also be deleted without a connection. More specifically: by mailcap, when it launches an external process without opening the output in a buffer.
* pager: unregister containers properly when headers are pendingbptato2024-03-143-14/+33
| | | | | 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-145-15/+1292
| | | | | | | | * 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-143-9/+62
| | | | | | only for source for now, rendered document is a bit more complicated (also, get rid of useless extern/editor module)
* pager: use loadinfo for redirection message, not alertbptato2024-03-131-1/+2
| | | | | alert has a tendency to pile up redirection infos. This is annoying and may obscure the "too many redirections" error message.
* client: fix blocking reads on container connectionbptato2024-03-123-43/+104
| | | | | | | | | | | | | | | | 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-123-30/+31
| | | | | | | 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: fix replacement logicbptato2024-03-122-27/+32
| | | | | | | | | This is what the original replacement logic was supposed to do, except it was broken. The previous fix might have been worse than the original bug. Now we do it like this: * if needed, replace buffer in gotoURL * deleteContainer swaps back the buffer it replaced, if it still exists * on connection success, kill the buffer we replaced
* pager: decrement numload on redirectbptato2024-03-121-0/+1
| | | | because gotoURL will increment it
* io: add dynstreambptato2024-03-122-2/+3
| | | | | a new abstraction that we derive posixstream from; hopefully with time we can get rid of std/streams
* pager: do not eat error alerts on startupbptato2024-03-112-2/+1
| | | | | cetStatus is only called for soft status updates, not alerts (we have cetAlert for that)
* loader: rework process modelbptato2024-03-113-607/+720
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* client: fix thumb button confusionbptato2024-03-111-18/+18
| | | | | | | | the 0x40 bitmask implies one more state than the 0 bitmask, since state 3 with 0 is unused[0]. so we must add 7, not 6 [0] it's reserved for "move", but movement is indicated differently in the protocol we use so unused
* client: bind middle button to discardBuffer, use button5/6 as scrollbptato2024-03-112-5/+14
| | | | | | middle button to close is from w3m btn5/6 is normally a horizontal scroll wheel, so scrollLeft/Right makes more sense than prev/next
* client: only accept "press" input type for scroll wheelbptato2024-03-111-2/+6
|
* pager: clear status message when opening external viewersbptato2024-03-041-0/+2
| | | | it used to leave "Connecting..." on the screen
* buffer: improve/fix onload return valuesbptato2024-03-032-14/+18
| | | | | | | | | 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.
* quickjs: reduce diff with upstreambptato2024-03-021-2/+3
| | | | | | * the uint8array thing is probably from txiki.js, but we never used it * upstream now has JS_GetClassID, importing that instead... (so this commit won't build :/)
* 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-293-10/+26
| | | | | | | | | | 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-293-24/+164
|
* pager: fix gotoURL crashingbptato2024-02-291-0/+1
| | | | | should finally convert the code to strictDefs, implicit result is a horrible footgun
* pager: improve URL loading procsbptato2024-02-281-5/+14
| | | | | | | Split up load into loadSubmit, gotoURL: loadSubmit is a replacement for load(s + '\n'), and gotoURL is a load that does no URL expansion. Also, fix a bug where load("\n") would crash the browser.
* 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).
* pager: do not add replacement containersbptato2024-02-261-1/+3
| | | | | they will replace the target container on connection, so inserting them in a different place first results in strange navigation bugs
* buffer: clean up onload, fix console updatebptato2024-02-262-42/+40
| | | | | | | | | | | | * 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-253-20/+17
| | | | | | | | | 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.)
* Separate ANSI text decoding from main binarybptato2024-02-252-45/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Handling text/plain as ANSI colored text was problematic for two reasons: * You couldn't actually look at the real source of HTML pages or text files that used ANSI colors in the source. In general, I only want ANSI colors when piping something into my pager, not when viewing any random file. * More importantly, it introduced a separate rendering mode for plaintext documents, which resulted in the problem that only some buffers had DOMs. This made it impossible to add functionality that would operate on the buffer's DOM, to e.g. implement w3m's MARK_URL. Also, it locked us into the horribly inefficient line-based rendering model of entire documents. Now we solve the problem in two separate parts: * text/x-ansi is used automatically for documents received through stdin. A text/x-ansi handler ansi2html converts ANSI formatting to HTML. text/x-ansi is also used for .ans, .asc file extensions. * text/plain is a separate input mode in buffer, which places all text in a single <plaintext> tag. Crucially, this does not invoke the HTML parser; that would eat NUL characters, which we should avoid. One blind spot still remains: copiousoutput used to display ANSI colors, and now it doesn't. To solve this, users can put the x-ansioutput extension field to their mailcap entries, which behaves like x-htmloutput except it first pipes the output into ansi2html.
* pager: fix wrong referrer in redirectTobptato2024-02-231-1/+1
|
* buffer: remove BufferSourcebptato2024-02-222-38/+30
| | | | | | | | | | 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-222-26/+36
| | | | | | | | | | 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).
* config: replace default-flags with ignore-casebptato2024-02-221-4/+10
| | | | | | default-flags was overly complicated for its purpose. Also, ignore-case is quite useful, so enable it by default.