about summary refs log tree commit diff stats
path: root/src/config
Commit message (Collapse)AuthorAgeFilesLines
* color: RGBAColor -> ARGBColorbptato2024-04-261-4/+4
|
* Initial image supportbptato2024-04-251-0/+4
| | | | | | | | | | | | | | | | | * 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
* js: fix some incorrect defineProperty usagebptato2024-04-211-2/+3
| | | | It consumes a value, so we must dup those that we pass.
* url, twtstr: correct number parsingbptato2024-04-181-10/+7
| | | | | | | | | * do not use std's parse*Int; they accept weird stuff that we do not want to accept in any case * fix bug in parseHost where a parseIpv4 failure would result in an empty host * do not use isDigit, isAlphaAscii * improve parse*IntImpl error handling
* Update code stylebptato2024-04-174-72/+69
| | | | | | * separate params with ; (semicolon) instead of , (colon) * reduce screaming snake case use * wrap long lines
* js: remove automatic function -> closure conversionbptato2024-04-151-8/+14
| | | | | | | | | | | | | | | 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: edit source fixesbptato2024-03-301-44/+48
| | | | | | | * 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
* ansi2html: support passing titlesbptato2024-03-291-0/+1
| | | | | | | Use content type attributes so e.g. git.cgi can set the title even with a text/x-ansi content type. (This commit also fixes some bugs in content type attribute handling.)
* config: improve input systembptato2024-03-262-6/+91
| | | | as described in <https://todo.sr.ht/~bptato/chawan/6>
* config, toml: rename enumsbptato2024-03-262-101/+101
|
* js: proper distinction between Opt/Optionbptato2024-03-241-34/+45
| | | | | | | | | | | | | | | | 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.
* config: add default-headers to siteconfbptato2024-03-211-14/+2
| | | | | | | 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.
* cell: update FormatFlag naming, remove useless templatesbptato2024-03-211-7/+7
|
* main: refactor slightlybptato2024-03-211-0/+3
| | | | | | * put forkServer into main() * use a ctx type instead of closures * get rid of types/opt import
* main: set CHA_LIBEXEC_DIR env var at startupbptato2024-03-191-15/+5
| | | | This way, we can use it everywhere (e.g. in mailcap).
* config: parse mime.types/mailcap/urimethodmap inside parseConfigbptato2024-03-182-85/+67
| | | | | | Better (and simpler) than storing them all over the place. extra: change lmDownload text to match w3m
* config: clean up/simplifybptato2024-03-173-243/+294
| | | | | | | | | * 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
* pager, loader: add "Save file to" functionalitybptato2024-03-161-7/+1
| | | | | | | 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-161-0/+1
| | | | useful for debugging
* Clean up BufferConfigbptato2024-03-151-43/+0
| | | | | | | | 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.
* loader: remove applyHeadersbptato2024-03-121-41/+18
| | | | | | | 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.)
* mailcap: better error messages, accept \ as newline escapebptato2024-03-111-6/+18
| | | | the backslash thing is in the RFC, I just forgot to add it
* loader: rework process modelbptato2024-03-113-18/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: do not incrementally display in headless modebptato2024-03-021-0/+2
|
* Add mouse supportbptato2024-02-291-0/+1
|
* term: improve pixels-per-column/line detectionbptato2024-02-251-0/+8
| | | | | | | | | 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-6/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* buffer: remove BufferSourcebptato2024-02-221-1/+2
| | | | | | | | | | 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.)
* config: replace default-flags with ignore-casebptato2024-02-221-1/+1
| | | | | | default-flags was overly complicated for its purpose. Also, ignore-case is quite useful, so enable it by default.
* Replace Chakasu with Chagashibptato2024-02-222-2/+2
| | | | | | The API is horrid :( but at least it copies less. TODO: think of a better API.
* regex: re-work compileSearchRegexbptato2024-02-171-5/+29
| | | | | | | 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-171-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | 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.)
* Various refactorings & fixesbptato2024-02-141-4/+3
| | | | | | | | * 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-2/+4
| | | | | | | | | | | | | | | | | | | | | | | 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.
* fix rejection of readFromFd urlsbptato2024-02-111-1/+1
|
* toml: misc refactoringsbptato2024-01-301-71/+40
|
* toml: allow EOF in values with laxnamesbptato2024-01-301-0/+2
| | | | Useful for clearing settings with -o
* config: append */* rule instead of prependingbptato2024-01-302-11/+3
| | | | | | + actually use the result. Fixes default converters when no external mailcap exists.
* Add default md2html converterbptato2024-01-301-14/+21
|
* mimetypes: simplify parseMimeTypesbptato2024-01-271-16/+9
| | | | | * use functions like until * do not call atEnd for every line, use boolean readLine instead
* cgi: fix broken libexec path env variablebptato2024-01-262-2/+3
|
* Add urlenc, urldec; fix a URL encoding bug; improve trans.cgibptato2024-01-081-1/+1
| | | | | | | | | | * Fix incorrect internal definition of the fragment percent-encode set * urlenc, urldec: these are simple utility programs mainly for use with shell local CGI scripts. (Sadly the printf + xargs solution is not portable.) * Pass libexec directory as an env var to local CGI scripts * Update trans.cgi to use urldec and add an example for combining it with selections
* Use std/* imports everywherebptato2024-01-074-15/+15
|
* config/toml: fix consumeComment overriding nodesbptato2023-12-151-1/+2
| | | | | We must first check if there is really no node to attach the comment to...
* config: allow overriding default prepended schemebptato2023-12-151-0/+1
|
* config: do not override user-defined urimethodmapbptato2023-12-141-1/+2
| | | | UMM resolution takes the first entry.
* chapath: add missing returnbptato2023-12-141-1/+2
|
* Various fixesbptato2023-12-131-1/+1
| | | | | | | * Makefile: fix parallel build, add new binaries to install target * twtstr: split out libunicode-related stuff to luwrap * config: quote default gopher2html URL env var for unquote * adapter/: get rid of types/url dependency, use CURL url in all cases
* Move gopher to adapter/bptato2023-12-121-10/+1
| | | | Also, move default urimethodmap config to res.
* Move out ftp: protocol; fix some local CGI bugsbptato2023-12-121-0/+3
|