about summary refs log tree commit diff stats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* buffer: reset prevStyled in switchCharset, reshapebptato2024-02-272-12/+8
| | | | | | | | 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).
* Update Chagashibptato2024-02-261-1/+1
|
* 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-263-59/+51
| | | | | | | | | | | | * 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).
* loader: clean up regular file loadingbptato2024-02-263-105/+105
| | | | | | | | | | | | | | | | | | | | * Get rid of sostream hack This is no longer needed, and was in fact causing loadStream to get stuck with redirects on regular files (i.e. the common case of receiving <file on stdin without a -T content type override). * Unify loading from cache and stdin regular file code paths Until now, loadFromCache was completely sync. This is not a huge problem, but it's better to make it async *and* not have two separate procedures for reading regular files. (In fact, loadFromCache had *another* bug related to its output fd not being added to outputMap.) * Extra: remove ansi2html select error handling It was broken, because it didn't handle read events before the error. Also unnecessary, since recvData breaks from the loop on n == 0.
* term: improve pixels-per-column/line detectionbptato2024-02-2515-370/+256
| | | | | | | | | 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 incorrect assertionsbptato2024-02-251-3/+0
| | | | | `confidence' becomes ccCertain when PRES_STOP is returned, so asserting the opposite is incorrect (and was resulting in crashes).
* css: always use defaultColor as the initial colorbptato2024-02-251-7/+4
| | | | | | | | | | This way, we do not end up with ugly contrast-corrected white on terminals with arbitrary backgrounds by default. (Now we get the native -cha-ansi(default) instead). (We leave background-color as transparent; this should have the same effect, since defaultColor as bgcolor is ignored, but makes more sense (and will allow us to un-ignore defaultColor as bgcolor in the future.))
* buffer: fix rewind with mailcap entriesbptato2024-02-254-10/+41
| | | | | | | | Cache mailcap entry output too, then delete it when the buffer can no longer read from it. (Maybe it would be useful to instead preserve it and allow viewSource for HTML output too? Hmm.)
* Separate ANSI text decoding from main binarybptato2024-02-259-260/+182
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* dom: use AttrType in DOMTokenList supportsbptato2024-02-241-5/+3
|
* dom: check rel attribute for link tags before downloadbptato2024-02-241-1/+1
|
* Allow non-RGB colors in CSSbptato2024-02-248-180/+252
| | | | | | | | | | | The -cha-ansi color type now sets ANSI colors in CSS. Also, color correction etc. has been improved a bit: * don't completely reset output state in processFormat for new colors * defaultColor is now separated from ANSI color type 0 * bright ANSI colors are no longer replaced with bold + dark variant * replaced ANSI color map to match xterm defaults
* layout: make it compile attempt 2bptato2024-02-241-2/+2
| | | | aaaaaa
* layout: make it compilebptato2024-02-241-2/+2
| | | | :/
* layout: make position: fixed, sticky act like staticbptato2024-02-241-7/+8
| | | | | | | | It's better to not implement them at all than to implement them badly. (In particular, making fixed act like absolute breaks horribly on websites that actually use it. Fixing it is not really possible without changinge the way we currently draw things to the screen.)
* dom: add onload content attribute to bodybptato2024-02-245-8/+49
|
* dom: print parse errors to consolebptato2024-02-242-13/+16
| | | | instead of trying to evaluate exceptions...
* loader: only add output fd to outputMap map in addFdbptato2024-02-241-3/+4
| | | | | | | | It is a very bad idea to add it before that, because it could be closed for various reasons without being removed from the map. More concretely, this was causing ghost ostream fds to block istream selects in some cases.
* pager: fix wrong referrer in redirectTobptato2024-02-231-1/+1
|
* buffer: improve cancel, use _exit, misc cleanupsbptato2024-02-233-50/+59
| | | | | | * cancel resources on cancel() call * call _exit in signal handler (also in loader) * misc cleanups
* Update Chagashibptato2024-02-231-1/+1
|
* buffer: remove BufferSourcebptato2024-02-226-106/+100
| | | | | | | | | | 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-223-44/+40
| | | | | | | | | | 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-222-5/+11
| | | | | | default-flags was overly complicated for its purpose. Also, ignore-case is quite useful, so enable it by default.
* Replace Chakasu with Chagashibptato2024-02-2218-341/+378
| | | | | | The API is horrid :( but at least it copies less. TODO: think of a better API.
* layout: remove justifybptato2024-02-221-20/+1
| | | | | | | | | | | | | | | | | | The way `justify' was implemented just made text annoying to read. (The algorithm of distributing spacing evenly does not really work on a cell-based screen because of rounding errors.) CSS 2.1 says: > Conforming user agents may interpret the value 'justify' as 'left' or > 'right', depending on whether the element's default writing direction > is left-to-right or right-to-left, respectively. Since we have no bidi yet, just interpret it as `left'. Maybe in the future we could add an implementation that tries to align line box lengths instead of their contents, but this will probably be difficult to get right.
* layout: do not apply error correction to first linebptato2024-02-221-5/+4
| | | | | | The first line is already ignored in the calculations, but it was still being re-positioned in positionAtoms, which made lines overlap in some cases.
* Update chamebptato2024-02-211-1/+1
|
* 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
* buffer: fix broken jump-to-anchorbptato2024-02-181-1/+1
| | | | | source.request.url is not used after buffer initialization (because it may be replaced later), so we must set buffer.url instead.
* regex: compileSearchRegex improvementsbptato2024-02-181-9/+7
| | | | | * do not eat \\c, \\C * emulate vi-style word boundary matching (\<, \>) with \b
* libregexp: cast flags to the right sizebptato2024-02-181-1/+1
| | | | We have less than 8 flags, so the set's size is 1.
* client: fix EOF error for estreambptato2024-02-181-0/+2
|
* pager: fix compilation on 1.6.14bptato2024-02-171-1/+1
|
* regex: re-work compileSearchRegexbptato2024-02-179-79/+127
| | | | | | | I've gotten tired of not being able to search for forward slashes. Now it works like in vim, and you can also set default ignore case in the config.
* term: fix coloring messbptato2024-02-173-32/+178
| | | | | | | | | | | | | | | | | | | | | | | | | Until now, the config file required manual adjustment for the output to look bearable on terminals colored differently than {bgcolor: black, fgcolor: white}. Also, it only detected RGB when COLORTERM was set, but this is not done by most (any?) terminal emulators (sad). To improve upon the situation, we now query the terminal for some attributes on startup: * OSC(10/11, ?) -> get the terminal's bg/fgcolor * DCS(+, q, 524742) -> XTGETTCAP for the "RGB" capability (only supported by a few terminals, but better than nothing) * Primary device attributes -> check if ANSI colors are supported, also make sure we don't block indefinitely even if the previous queries fail If primary device attributes does not return anything, we hang until the user types something, then notify the user that something went wrong, and tell them how to fix it. Seems like an OK fallback. (The DA1 idea comes from notcurses; since this is implemented by pretty much every terminal emulator, we don't have to rely on slow timing hacks to skip non-supported queries.)
* winattrs: remove unnecessary call, fix height_px fallbackbptato2024-02-173-6/+6
| | | | no need for every new buffer to query the window size
* css: reduce CSSComputedValue sizebptato2024-02-172-118/+96
| | | | | | | The `t' field was completely redundant, as it's already included in the CSSComputedValues index. + removed some unused functions
* More bgcolor fixesbptato2024-02-171-10/+7
| | | | | | * fix accidental dependency on previously chosen bgcolor (ouch) * also draw empty background boxes for bgcolor-is-canvas boxes * remove unused variable
* layout: use html/body bgcolor as canvas bgcolorbptato2024-02-176-46/+74
| | | | | | 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.)
* layout: only reset charwidth on non-word atomsbptato2024-02-161-1/+1
| | | | | | | | charwidth is specifically intended to represent the width of all characters until the current one, so resetting it for words makes no sense. Originally it was reset for all atoms *except* words; 9fdea97d simplified the code incorrectly (flipped the logic) and thus introduced a regression.
* container: set color on double width char + tab fillersbptato2024-02-161-7/+10
|
* layout: avoid wrapping on dash inside double-width linesbptato2024-02-161-0/+4
| | | | | Without this we were wrapping on the last dash (if any) inside CJK sentences.
* so close!bptato2024-02-151-5/+7
| | | | but I forgot to ensure the output stream gets closed. :(
* loader: fix crash on file redirection inputsbptato2024-02-152-16/+60
| | | | | | | | cha -d <some-file was crashing loader, because it was trying to register the regular file in the selector. this patch fixes the problem, but the control flow of loader looks like spaghetti now
* pager: increase numload for stdinbptato2024-02-151-0/+1
| | | | otherwise pages from stdin have a race condition in dump
* dom: fix href stringifierbptato2024-02-151-0/+2
| | | | Return the empty string if it's unset.
* pager: enable wait in runMailcapWritePipebptato2024-02-141-1/+1
| | | | | | Otherwise, container will just happily kill the buffer and with it the loader process before it would have had the chance to stream out the input into the external process.
* Various refactorings & fixesbptato2024-02-1413-243/+127
| | | | | | | | * 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