about summary refs log tree commit diff stats
path: root/src/local
Commit message (Collapse)AuthorAgeFilesLines
* Remove unnecessary unsigned castsbptato2024-04-261-2/+2
| | | | | Unsigned operations and conversions to unsigned types always wrap/narrow without checks, so no need to manually mask/cast/etc. them.
* pager: reduce unnecessary image redrawsbptato2024-04-261-1/+1
| | | | the status line can't have images, so this should work
* term: add sixel encoderbptato2024-04-251-84/+179
|
* Initial image supportbptato2024-04-253-16/+95
| | | | | | | | | | | | | | | | | * 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-183-6/+26
| | | | | | | | | | | | | | | | | 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-176-203/+207
| | | | | | * separate params with ; (semicolon) instead of , (colon) * reduce screaming snake case use * wrap long lines
* term: save/restore title after "set title"bptato2024-04-161-2/+12
| | | | | | | | | It is quite straightforward, because XTerm has a functionality to do just this. (In fact, it automatically restores the title when I use smcup/rmcup. But when I don't, it will linger until I close the window or change the title again.)
* js: remove automatic function -> closure conversionbptato2024-04-151-14/+28
| | | | | | | | | | | | | | | 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.
* term: do not eat last DA1 valuebptato2024-04-101-3/+9
|
* pager: fix incremental search with empty stringbptato2024-03-301-3/+11
| | | | | | | | | | | | | | This is broken in w3m too, so we take nvi behavior instead. Also, we now consistently complain when the user tries to search for an empty string instead of just occasionally spitting out "invalid regex" alerts. (In w3m, /search^M/^M just jumps to the first search result with ISEARCH. In nvi, it jumps to the second one with both searchincr on and off. w3m only produces the latter behavior with regular search, which is I assume why I made it work this way, but it's still inconsistent for no good reason.)
* 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-302-1/+9
|
* pager: edit source fixesbptato2024-03-301-27/+8
| | | | | | | * 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
* term: flush stdout in anyKeybptato2024-03-291-0/+1
|
* pager: fix broken writeToFilebptato2024-03-291-5/+1
|
* fflush() before forksbptato2024-03-281-6/+11
| | | | | seems like a good idea, especially because CGI uses stdout as the IPC mechanism
* Add capsicum supportbptato2024-03-281-2/+5
| | | | | | | | | | | | | It's the sandboxing system of FreeBSD. Quite pleasant to work with. (Just trying to figure out the basics with this one before tackling the abomination that is seccomp.) Indeed, the only non-trivial part was getting newSelector to work with Capsicum. Long story short it doesn't, so we use an ugly pointer cast + assignment. But even that is stdlib's "fault", not Capsicum's. This also gets rid of that ugly SocketPath global.
* term: improve color detectionbptato2024-03-271-5/+16
| | | | | some terminals (alacritty) don't support XTGETTCAP and don't even respond with ANSI color support to DA1, so just fall back to termcap.
* container: rename enumsbptato2024-03-271-17/+17
|
* buffer: fix cancel()bptato2024-03-272-11/+33
| | | | | | | | | | * 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
* config: improve input systembptato2024-03-261-8/+10
| | | | as described in <https://todo.sr.ht/~bptato/chawan/6>
* config, toml: rename enumsbptato2024-03-261-13/+13
|
* pager: percent-decode path name in askDownloadPathbptato2024-03-251-1/+1
|
* client, forkserver: remove useless codebptato2024-03-241-1/+0
|
* js: proper distinction between Opt/Optionbptato2024-03-241-6/+6
| | | | | | | | | | | | | | | | 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.
* buffer: fix clonebptato2024-03-241-3/+3
|
* io: derive DynStream from RootObj (not Stream)bptato2024-03-243-55/+62
| | | | | | | | 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.)
* pager: detect JS as textbptato2024-03-241-1/+5
| | | | | hack so it's possible to view JS code in a buffer even if it's set as e.g. application/javascript in user mime.types
* io: add bufreaderbptato2024-03-211-1/+1
| | | | analogous to bufwriter
* config: add default-headers to siteconfbptato2024-03-211-19/+7
| | | | | | | 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.
* term: use termcap for italic resetbptato2024-03-211-3/+7
|
* libregexp: update LRE_FLAG_UTF16 namebptato2024-03-211-1/+1
| | | | upstream now calls it unicode
* cell: update FormatFlag naming, remove useless templatesbptato2024-03-213-18/+18
|
* 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-212-4/+6
| | | | this is buffer reading from pager
* pager: fix flipped predicate for downloadbptato2024-03-211-1/+1
| | | | we want to check if it's *not* text.
* client: fix dump detectionbptato2024-03-201-7/+7
| | | | it wouldn't start dump mode if stdout was not a tty but stdin was.
* pager: add "save link", "save source"; change & document some keybindingsbptato2024-03-203-63/+111
| | | | | | | | | * `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
* pager: do not ask to download text/*bptato2024-03-191-1/+1
| | | | it's text, so we can display it anyway.
* buffer: add markURLbptato2024-03-192-3/+14
| | | | Useful when browsing plaintext files; w3m has it too.
* client: refactor inputbptato2024-03-183-164/+146
| | | | | * move mouse handling to term * do not use File for input just to disable buffering anyway
* config: parse mime.types/mailcap/urimethodmap inside parseConfigbptato2024-03-182-18/+9
| | | | | | Better (and simpler) than storing them all over the place. extra: change lmDownload text to match w3m
* 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.)