about summary refs log tree commit diff stats
path: root/src/local/client.nim
Commit message (Collapse)AuthorAgeFilesLines
* client: only accept "press" input type for scroll wheelbptato2024-03-111-2/+6
|
* buffer: improve/fix onload return valuesbptato2024-03-031-5/+4
| | | | | | | | | 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 :/)
* buffer, client: fix deadlock with send() callsbptato2024-02-291-1/+16
| | | | | | | | | | 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-8/+138
|
* buffer: clean up onload, fix console updatebptato2024-02-261-2/+1
| | | | | | | | | | | | * 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-5/+2
| | | | | | | | | 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-251-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Replace Chakasu with Chagashibptato2024-02-221-1/+1
| | | | | | The API is horrid :( but at least it copies less. TODO: think of a better API.
* client: fix EOF error for estreambptato2024-02-181-0/+2
|
* Various refactorings & fixesbptato2024-02-141-17/+28
| | | | | | | | * 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
* Remove CLONE BufferSource; cache document sources in tmpdirbptato2024-02-121-3/+0
| | | | | | | | | | | | | | | | | | | | | | | 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.
* Get rid of LOAD_PIPE BufferSourcebptato2024-02-111-3/+3
| | | | | Instead, use a stream: scheme and associate hostnames with file descriptors directly from the pager.
* forkserver: clean upbptato2024-01-291-4/+2
| | | | | Move forkBuffer into forkserver (why was it in container anyway), remove unused mainproc variable, etc.
* client: stop entire process group on suspend()bptato2024-01-291-1/+1
| | | | | * pass 0 so e.g. git does not hang * use sigtstp so e.g. cgi scripts can clean up if needed
* Remove std/terminal dependencybptato2024-01-171-1/+0
| | | | It is mostly unnecessary, and conflicts with our use of termcap anyway.
* js: merge some type modules into jstypesbptato2024-01-111-1/+1
| | | | They only had type definitions, no need to put them in separate modules.
* Use std/* imports everywherebptato2024-01-071-11/+11
|
* Set cgiDir for client loader processbptato2024-01-061-1/+3
|
* Compile with styleCheck:usagesbptato2023-12-281-3/+3
| | | | much better
* client: nil check connectSocketStream resultbptato2023-12-141-0/+5
| | | | | It may fail if the buffer process could not successfully create a server socket.
* client: avoid nil defect in flushConsolebptato2023-12-141-0/+5
|
* pager: add marksbptato2023-12-091-0/+7
| | | | | Default is vi-style, but w3m-style marks work as well; see bonus/w3m.toml.
* pager, container: add text selection/copyingbptato2023-12-031-11/+23
| | | | | | | | | | * Add select & copy selection functionality to container * Fix bug in generateSwapOutput where output could be misplaced because of zero-width cells * Add fromJSPromise, call runJSJobs in every iteration of the headed event loop * "await" pager actions that output a promise * Change default view source keybinding to `\'
* Get rid of clang 16 workaroundbptato2023-12-021-5/+6
| | | | | * bindings/quickjs: importc and use correct pointer types * add constcharp module for when it is unavoidable
* pager: fix regressionbptato2023-11-211-14/+14
| | | | | pager.tty refers to infile, not outfile. rename to avoid further confusion
* Remove trailing spacesbptato2023-10-231-1/+1
|
* base64: reduce pointless re-coding using JSStringbptato2023-10-211-2/+3
| | | | | We now expose some functions from QuickJS to interact with JavaScript strings without re-encoding them into UTF-8.
* javascript: add TextEncoder, TextDecoderbptato2023-10-211-0/+2
|
* WindowAttributes: refactorbptato2023-10-191-1/+1
| | | | | | * rename module (window -> winattrs, to avoid conflict with env/window) * do not use result * remove unused cell_ratio
* Refactor Consolebptato2023-10-131-70/+96
| | | | | * merge dom.console & client.Console * move client-specific stuff out of Console (into callbacks when necessary)
* Add w3m-cgi-compat optionbptato2023-10-011-1/+2
|
* Add urimethodmap supportbptato2023-09-301-0/+1
| | | | yay
* pager: show character sequence inputs on status linebptato2023-09-261-23/+25
| | | | pretty useful I think
* client: write errors to browser console in evalActionbptato2023-09-251-3/+10
|
* client: clean up Client objectbptato2023-09-241-14/+5
| | | | | * remove unused attributes * make line a function
* client, timeout: simplifybptato2023-09-241-8/+8
| | | | | We don't use the generic feature of selectors, so just unify the client & buffer timeout types.
* Disable "toggle source" for the console bufferbptato2023-09-211-1/+2
|
* Fix compilation with --assertions:offbptato2023-09-151-2/+4
| | | | | Remove side effects from assert statements. The flag is not used currently, but let's not depend on that.
* bindings: fix JSInterruptHandler signaturebptato2023-09-151-1/+1
|
* move around more modulesbptato2023-09-141-8/+8
| | | | | | | | | | * ips -> io/ * loader related stuff -> loader/ * tempfile -> extern/ * buffer, forkserver -> server/ * lineedit, window -> display/ * cell -> types/ * opt -> types/
* move some modules to local/bptato2023-09-141-0/+643
makes a bit more sense than the previous arrangement