aboutsummaryrefslogtreecommitdiff
path: root/render.c (follow)
Commit message (Collapse)AuthorAgeLines
* render: sixels: render cursor, if it’s partially covered by an opaque sixelDaniel Eklöf2021-03-11-1/+3
|
* sixel: implement P2=1 - transparent pixelsDaniel Eklöf2021-03-11-30/+44
| | | | | | | | | | | | | | | | | | | | | | | | When P2=1, empty pixels are transparent. This patch also changes the behavior of P2=0|2, from setting empty pixels to the default background color, to instead use the *current* background color. To implement this, a couple of changes are needed: * Sixel pixels always use alpha=1.0, except for *empty* cells when P2=1 (i.e. transparent pixels). * The renderer draws sixels with the OVER operator, instead of the SRC operator. * The renderer *must* now render the cells beneath the sixel. As an optimization, this is only done for sixels where P2=1. I.e. for fully opaque sixels, there’s no need to render the cells beneath. The sixel renderer isn’t yet hooked into the multi-threaded renderer. This means *rows* (not just the cells) beneath maybe-transparent sixels are rendered single-threaded. Closes #391.
* render: jump-labels: case insensitive comparison when looking for matching keysDaniel Eklöf2021-03-04-1/+1
|
* url-mode: snapshot screen state when entering URL modeDaniel Eklöf2021-02-26-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | Previously, we automatically exited URL mode whenever we received data on the PTY. This was done since we don’t know _what_ has changed on the screen, and we don’t want to display misleading jump labels. However, this becomes a problem in curses-like applications that periodically updates part of the screen. For example, a statusbar with a clock. This patch changes this behavior; instead of cancelling URL mode when receiving PTY data, we snapshot the grid when entering URL mode. When *rendering*, we use the snapshot:ed grid, while PTY updates modify the “real” grid. Snapshot:ing the grid means taking a full/deep copy of the current grid, including sixel images etc. Finally, it isn’t necessary to “damage” the entire view when *entering* URL mode, since we’re at that point the renderer is in sync with the grid. But we *do* need to damage the entire view when exiting URL mode, since the grid changes on the “real” grid hasn’t been tracked by the renderer.
* urls: add key binding that toggles whether URLs are displayed on jump-labelDaniel Eklöf2021-02-21-2/+19
| | | | | | | | | | | | | | | | | By default, the URL isn’t shown on the jump-label. For auto-detect URLs, doing so is virtually always useless, as the URL is already visible in the grid. For OSC-8 URLs however, the URL is often _not_ visible in the grid. Many times, seeing the URL is still not needed (if you’re doing ‘ls --hyperlink’, you already know what the URIs are). But it is still useful to have a way to show the URLs. This patch adds a new key binding action that can be used in url-mode to toggle the URL on and off in the jump label. It is bound to ctrl+t by default.
* urls: remove free-form ‘text’ member from URL structDaniel Eklöf2021-02-21-12/+2
|
* url-mode: multiple URL (parts) with the same ID is assigned a single key sequenceDaniel Eklöf2021-02-21-0/+6
| | | | | | | | | | In case an URL is split up into multiple parts, those parts are now treated as a single URL when it comes to key assignment. Only the *first* URL part is actually assigned a key combo. The other parts are ignored. We still highlight them, but for all other purposes they are ignored.
* wayland: drop ‘_surface’ suffix from subsurface struct instancesDaniel Eklöf2021-02-17-21/+21
|
* render-timer: use wayl_win_subsurface_new/destroy()Daniel Eklöf2021-02-17-2/+3
|
* scrollback-indicator: use wayl_win_subsurface_new/destroy()Daniel Eklöf2021-02-17-34/+9
|
* search: use wayl_win_subsurface_new/destroy()Daniel Eklöf2021-02-17-9/+9
|
* csd: use wayl_win_subsurface_new/destroy()Daniel Eklöf2021-02-17-5/+5
|
* url-mode: convert struct wl_url to use wayl_win_subsurface_new()Daniel Eklöf2021-02-17-2/+2
|
* render: block all signals in the rendering threadsDaniel Eklöf2021-02-11-0/+5
|
* Convert all but 2 remaining uses of xassert(false) to BUG("...")Craig Barnes2021-02-10-2/+2
|
* Convert some more uses of xassert(false) to BUG("...")Craig Barnes2021-02-09-1/+1
|
* Convert some uses of xassert(false) to BUG("some error message")Craig Barnes2021-02-09-3/+2
|
* render: use portable HAS_INCLUDE() wrapper instead of __has_include()Craig Barnes2021-02-09-1/+3
|
* render: urls: blank out keys already pressedDaniel Eklöf2021-02-07-6/+3
|
* render: urls: fix string formatter in swprintf()Daniel Eklöf2021-02-07-1/+1
|
* render: urls: don’t use/allocate maximum allowed characters unless neededDaniel Eklöf2021-02-07-1/+1
|
* render: render_osd(): remove ‘alpha’ parameter - it’s always 0xffffDaniel Eklöf2021-02-07-8/+6
|
* render: urls: reduce vertical marginDaniel Eklöf2021-02-07-5/+6
|
* render: urls: uppercase the activation key sequenceDaniel Eklöf2021-02-07-0/+4
|
* render: urls: add TODO: highlight already entered keysDaniel Eklöf2021-02-07-0/+6
|
* render: urls: don’t display URLs whose key sequence doesn’t matchDaniel Eklöf2021-02-07-1/+10
|
* url-mode: underline URLs using the color from colors.urlsDaniel Eklöf2021-02-07-0/+9
| | | | | | | | | | | | | | | | | | | | | | This is implemented by allocating one of the (few!) remaining bits in the cells’ attribute struct to indicate the cell should be “URL highlighted”. render_cell() looks at this bit and draws an underline using the color from colors.urls (defaults to regular3 - i.e. yellow). A new function, url_tag_cells(), iterates the currently detected URLs and sets the new ‘url’ attribute flag on the affected cells. Note: this is done in a separate function to keep urls_collect() free from as many dependencies as possible. urls_reset() is updated to *clear* the ‘url’ flag (and thus implicitly also results in a grid refresh, _if_ there were any URLs). We now exit URL mode on *any* client application input. This needs to be so since we can’t know if the URLs we previously detected are still valid.
* url-mode: store absolute row numbers in start/end coordinatesDaniel Eklöf2021-02-07-3/+29
| | | | | | | | | | | | | | | | | This allows us to update the jump label positions when the viewport changes. This in turn allows us to stay in URL mode while the user is using the mouse to scroll in the scrollback history. Scrolling with the keyboard is currently not possible, since input handling in URL mode does not recognize “regular” key bindings. We _could_ add scrollback up/down bindings to URL mode too, but lets not, for the time being. (Note: an alternative to this patch is to disallow mouse scrolling too. Then we could have kept the URL start/end as viewport local coordinates).
* config: use a bitfield for flags tracking whether to use custom colors for CSD or notDaniel Eklöf2021-02-07-5/+5
|
* config: add colors.jump_labels and colors.urlsDaniel Eklöf2021-02-07-2/+10
| | | | | | | | | | * colors.jump_labels configures the foreground and background colors used when rendering URL jump labels. Defaults to “regular0 regular3” (i.e. black on yellow). * colors.urls configures the color to use when highlighting URLs in URL mode. Note that we aren’t currently doing any highlighting... Defaults to regular3 (i.e. yellow).
* config: use a packed bitfield for “use custom color” flagsDaniel Eklöf2021-02-07-1/+1
|
* render: urls: tweak positioningDaniel Eklöf2021-02-07-4/+6
| | | | Don’t offset the labels too much vertically, _or_ horizontally.
* render: reduce URL jump label marginsDaniel Eklöf2021-02-07-1/+1
|
* render: url labels: don’t position outside windowDaniel Eklöf2021-02-07-2/+11
|
* render: urls: positioning: place a bit further away from the starting positionDaniel Eklöf2021-02-07-2/+2
|
* urls: initial support for detecting URLs and rendering jump-labelsDaniel Eklöf2021-02-07-26/+97
| | | | The jump labels work, but is currently hardcoded to use xdg-open
* Send text_input_rectangle requests for text-inputTadeo Kondrak2021-01-29-1/+30
|
* config: promote tweak.resize-delay-ms to a real, supported optionDaniel Eklöf2021-01-26-3/+3
|
* render: remove unneeded paranthesesDaniel Eklöf2021-01-26-1/+1
|
* render: don’t center content while doing an interactive resizeDaniel Eklöf2021-01-26-1/+1
|
* render: remove debug loggingDaniel Eklöf2021-01-26-4/+1
|
* render: codespell: tiemout -> timeoutDaniel Eklöf2021-01-26-1/+1
|
* render: delay TIOCSWINSZ while doing an interactive resizeDaniel Eklöf2021-01-26-12/+92
| | | | | | | | | | | | | | | | | | | Instead of disabling content centering, delay the TIOCSWINSZ (a.k.a delay sending the new dimensions to the client) by a small amount while doing an interactive resize. Non-interactive resizes are still immediate. For now, force a resize when the user stops the interactive resize. This ensures the client application receives the new dimensions immediately. It still works without the last, forced, resize, but there typically be a small delay until the client application receives the final dimensions. Closes #301 Closes #283
* render: don’t center content while we’re being resizedDaniel Eklöf2021-01-26-1/+1
| | | | | Doing so causes the content to jump around while interactively resizing the window.
* ime: fix rendering of pre-edit cursor when positioned after the pre-edit stringDaniel Eklöf2021-01-26-1/+12
| | | | | | | | | | | | We failed to convert the byte-indices to cell indices, resulting in a box cursor covering the entire pre-edit string. Note that in addition to fixing the translation from byte index to cell index, the rendered had to be updated to dirty one extra cell from the original grid. Without this, we left trailing cursors behind us when the user deleted text from the pre-edit string.
* search: ad-hoc workaround for combining characters with positive x-offsetsDaniel Eklöf2021-01-26-2/+8
| | | | | | | | | | | | When rendering the search input box, do the same ad-hoc workaround for combining characters with a positive x-offset as we do when rendering normal grid cells. In this case, we don’t *know* when we’re dealing with combining characters. But we can detect zero-width characters. For these, check their glyph’s x-offset. If positive, adjust it like we do when rendering combining glyphs in the main grid, to ensure the glyph is positioned over the _previous_ character, not the next.
* render: set thread name in a portable wayJan Beich2021-01-23-2/+8
| | | | | | | | | | | | | | | | | | prctl is Linux-only but pthread_setname_np is same as PR_SET_NAME. Solaris and FreeBSD >= 13 have pthread_setname_np similar to Linux. DragonFly, OpenBSD, FreeBSD < 13 lack pthread_setname_np but provide pthread_set_name_np which doesn't return a value. NetBSD requires 3 arguments for pthread_setname_np where the last one is void *. render.c:8:10: fatal error: 'sys/prctl.h' file not found #include <sys/prctl.h> ^~~~~~~~~~~~~ render.c:1234:9: error: implicit declaration of function 'prctl' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if (prctl(PR_SET_NAME, proc_title, 0, 0, 0) < 0) ^ render.c:1234:15: error: use of undeclared identifier 'PR_SET_NAME' if (prctl(PR_SET_NAME, proc_title, 0, 0, 0) < 0) ^
* debug: rename assert() to xassert(), to avoid clashing with <assert.h>Craig Barnes2021-01-16-66/+66
|
* config: line-height, letter-spacing: values are in pt by default, but we allow pxDaniel Eklöf2021-01-11-4/+4
| | | | | | | | If the value is specified without a unit, then the value is assumed to be in points, subject to DPI scaling. The value can optionally have a ‘px’ suffix, in which case the value is treated as a raw pixel count.
* render: offset all glyphs with {horizontal,vertical}-letter-offsetDaniel Eklöf2021-01-11-7/+12
|
* Merge branch 'center-grid-content'Daniel Eklöf2021-01-07-4/+14
|\ | | | | | | Closes #273
| * config: add optional ‘center’ argument to ‘pad’Daniel Eklöf2021-01-06-4/+14
| | | | | | | | | | | | | | | | | | | | When set, the grid contents is centered in the window. I.e. the left/right and top/bottom margins are equal (+- 1px). This causes the content to “jump” while doing an interactive resize, but may still be preferred in e.g. a tiling WM. Closes #273
* | render: sixel: fix assertion: x/y coords may be outside visible areaDaniel Eklöf2021-01-06-2/+2
|/ | | | But when they are, width/height must be 0.
* render: codespell: accomodate -> accommodateDaniel Eklöf2021-01-04-1/+1
|
* render: draw combining characters on top of colored bitmap glyphs (emoji)Daniel Eklöf2021-01-04-16/+34
|
* Use wrappers from macros.h instead of bare GCC attributes/pragmasCraig Barnes2021-01-03-1/+1
|
* Merge branch 'box-drawing'Daniel Eklöf2021-01-02-1/+22
|\ | | | | | | Closes #198
| * box-drawing: SEXTANTS, U+1fb00-1fb3bDaniel Eklöf2021-01-01-2/+3
| |
| * box-drawing: add infrastructure for rendering box drawing characters ourselvesDaniel Eklöf2021-01-01-1/+21
| | | | | | | | | | | | | | | | * ‘term’ struct contains an array of 160 fcft glyph pointers * the glyph pointers are lazily allocated when we need to draw a box drawings character * Filtering out box drawings characters is easy - they are (except unicode 13, which isn’t handled yet )all in a single range.
* | render: mark cell overflowed into as dirtyDaniel Eklöf2021-01-02-1/+10
|/ | | | | | | | | | | | | | | | When tweak.allow-overflowing-double-width-glyphs=yes, then certain glyphs are allowed to overflow into the neighbouring cell. However, if the cell “owning” the double-width glyph is erased (_only_ that cell), then the cell overflowed into is not redrawn, causing part of the double-width glyph to remain on screen. To avoid checking for these glyphs when printing to the terminal (i.e at parse time), simply mark both cells as dirty when we render the overflowing glyph. Yes, this means that the cells will always be re-rendered. We count on them only making up a small portion of the screen.
* render: fix rounding error when calculating background color with alphaDaniel Eklöf2020-12-20-7/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | We use pre-multiplied alpha color channels, but were having bad rounding errors due to the alpha divider being truncated to an integer. The algorithm for pre-multiplying a color channel is: alpha_divider = 0xffff / alpha pre_mult_color = color / alpha_divider In order to fix the rounding errors, we could turn ‘alpha_divider’ into a double. That however would introduce a performance penalty since now we’d need to do floating point math for each cell. The algorithm can be trivially converted to: pre_mult_color = color * alpha / 0xffff Since both color and alpa values are < 65536, the multiplication is “safe”; it will not overflow an uint32_t. Closes #249
* render: ime: ensure cursor is visibleDaniel Eklöf2020-12-08-13/+41
|
* render: search: render IME pre-edit text correctly, hopefullyDaniel Eklöf2020-12-07-61/+116
|
* render: ime: adjust cursor cell index when adjusting glyph offsetDaniel Eklöf2020-12-07-1/+4
|
* render: ime: wip: pre-editDaniel Eklöf2020-12-07-22/+75
|
* render: search: don’t access term->search.buf[] directlyDaniel Eklöf2020-12-07-8/+11
|
* render: codespell: cound -> countDaniel Eklöf2020-12-07-1/+1
|
* render: search: glyph_offset is in *cells*, cursor position in *characters*Daniel Eklöf2020-12-07-18/+64
| | | | | | When calculating the offset into the search string, from where to start rendering, take into account that the cursor position is in *characters*, and the glyph-offset is in *cells*.
* render: search: wcsnlen() -> wcswidth()Daniel Eklöf2020-12-07-1/+1
|
* render: search: handle multi-column charactersDaniel Eklöf2020-12-07-2/+3
|
* render: search: render colorized glyphs (emojis) correctlyDaniel Eklöf2020-12-07-5/+13
|
* render: ime: don’t render pre-edit string in grid while searchingDaniel Eklöf2020-12-07-0/+3
| | | | | | | | | While doing a scrollback search, the pre-edit string should be rendered in the search box, not in the grid. Note that we don’t yet support IME in scrollback search mode. This patch simply prevents the pre-edit text being rendered in the grid, in the “background”, while searching.
* render: ime: draw a ‘bar’ cursor when the pre-edit cursor’s begin == endDaniel Eklöf2020-12-07-6/+14
|
* render: ime: don’t render cursor if cursor begin == endDaniel Eklöf2020-12-07-3/+4
|
* render: ime: calculate on-screen cursor position ourselvesDaniel Eklöf2020-12-07-3/+12
| | | | | | | | The position calculated by render_grid() may be -1,-1 if the cursor is currently hidden. This fixes a crash when trying to input IME while the cursor is hidden.
* render: ignore IME preedit state when deciding which cursor style to renderDaniel Eklöf2020-12-07-1/+1
|
* ime: make IME compile-time optionalDaniel Eklöf2020-12-07-0/+3
|
* ime: render pre-edit textDaniel Eklöf2020-12-07-19/+127
| | | | | | | | | | | | | | This is done by allocating cells for the pre-edit text when receiving the text-input::done() call, and populating them by converting the utf-8 formatted pre-edit text to wchars. We also convert the pre-edit cursor position to cell positions (it can cover multiple cells). When rendering, we simply render the pre-edit cells on-top off the regular grid. While doing so, we also mark the underlying, “real”, cells as dirty, to ensure they are re-rendered when the pre-edit text is modified or removed.
* config: replace union in config struct with simple width/height membersCraig Barnes2020-11-30-4/+4
|
* resize: don’t reflow text on alt screenDaniel Eklöf2020-11-25-9/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Alt screen applications normally reflow/readjust themselves on a window resize. When we do it too, the result is graphical glitches/flashes since our re-flowed text is rendered in one frame, and the application re-flowed text soon thereafter. We can’t avoid rendering some kind of re-flowed frame, since we don’t know when, or even if, the application will update itself. To avoid glitches, we need to render, as closely as possible, what the application itself will render shortly. This is actually pretty simple; we just need to copy the visible content over from the old grid to the new grid. We don’t bother with text re-flow, but simply truncate long lines. To simplify things, we simply cancel any active selection (since often times, it will be corrupted anyway when the application redraws itself). Since we’re not reflowing text, there’s no need to translate e.g. the cursor position - we just keep the current position (but bounded to the new dimensions). Fun thing: ‘less’ gets corrupted if we don’t leave the cursor at the (new) bottom row. To handle this, we check if the cursor (before resize) is at the bottom row, and if so, we move it to the new bottom row. Closes #221
* render: don’t call term_arm_blink_timer() from multiple threadsDaniel Eklöf2020-11-23-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | We call term_arm_blink_timer() from render_cell(), which runs in multiple threads. This caused multiple blink timer FDs to be created and registered with the FDM, later causing read failures after one of those FDs had been closed again. This rarely happened under normal circumstances, but was easy to trigger when the whole screen was full of blinking text. As a small optimization, we don’t bother taking the lock if the timer FD already is valid. This is safe, because: 1) If the timer FD isn’t valid, we take the lock and then call term_arm_blink_timer(), which again checks if the FD is already valid. 2) The blink timer FD cannot be closed while we’re rendering cells. It is only disabled in the FDM callback, which cannot execute while we’re rendering.
* render: no need to call attrs_to_font(), we already have a font referenceDaniel Eklöf2020-11-22-8/+4
|
* render: allow-overflow: require a space in the next cellDaniel Eklöf2020-11-19-1/+5
| | | | | | | | When checking if we should allow a single-width character double-width glyph to overflow into the next cell, require the next cell to either be empty, or contain a space. Closes #203
* render: dim/brighten: multiply/divide instead of add/subtractDaniel Eklöf2020-11-15-2/+2
|
* render: dim and brighten colors by adjusting luminanceDaniel Eklöf2020-11-15-27/+30
| | | | | To do this, we need to convert our RGB to HSL, adjust luminance, and then convert back to RGB.
* render: remove debug outputDaniel Eklöf2020-11-15-1/+0
|
* render: brighten color of bold text if default.bold-text-in-bright=yesDaniel Eklöf2020-11-14-0/+10
| | | | Closes #199
* render: improve sixel rendering performanceDaniel Eklöf2020-11-13-43/+132
| | | | | | | | | | | | | | | | | | Up until now, we’ve always re-rendered the entire image (the part of it that is visible at least), *every* time we render a frame. This is not really needed. In many cases, the cells covered by the image hasn’t been touched. Rewrite the sixel rendering code to only render the part of the sixel image that covers dirty cells. This is done on a per-row basis. I.e. Each *row* of the image that covers at least one dirty cell is re-rendered. For this to work, we now also dirty all cells covered by the image when we emit the image. Finally, for this to work, the sixels need to be rendered *before* we do the normal grid render pass (since that will clear all dirty bits).
* tiocswinsz: fix compilation error on e.g. ppc64Daniel Eklöf2020-10-29-1/+1
| | | | | | | | | | | | | | | | | | | | | | | On some platforms, TIOCSWINSZ has a very large value, > 0x80000000. On some platforms, the `request` argument to `ioctl(3)` is an `int`. For platforms where both of the above is true, gcc will warn (and error out if compiled with `-Werror`) on: ioctl(fd, TIOCSWINSZ, ...) To silence this warning, we need to cast `TIOCSWINSZ` to an integer. However, doing this on platforms where `request` is an `unsigned long` will result in `TIOCSWINSZ` being sign-extended (and thus we end up with an invalid value). It seems that casting to `unsigned int` works in both cases; it silences the long -> int conversion warning, while also preserving the correct value in all cases.
* render: blink switches between foreground and dimmed foregroundDaniel Eklöf2020-10-22-3/+3
|
* wayland: properly restore window size when being un-tiledDaniel Eklöf2020-10-20-6/+11
| | | | | | | | Bind to xdg-shell version 2 if available, as this enables us to track our window’s ‘tiled’ state in the ‘configure’ events. This in turn allows us to stash the ‘old’ window size when being tiled, to be used again when restoring the window size when un-tiled.
* render: resize: call sixel_reflow() after reflowing gridsDaniel Eklöf2020-10-09-0/+3
|
* bell: optionally render margins in red when receiving BELDaniel Eklöf2020-10-08-0/+32
| | | | | | | | | | | Add anew config option, ‘bell=none|set-urgency’. When set to ‘set-urgency’, the margins will be painted in red (if the window did not have keyboard focus). This is intended as a cheap replacement for the ‘urgency’ hint, that doesn’t (yet) exist on Wayland. Closes #157
* render: apply opacity correctly when in reverse video modeDaniel Eklöf2020-10-08-2/+8
|
* render: remove render_refresh_margins()Daniel Eklöf2020-09-29-6/+0
|
* render: term->render.margins is used to explicitly tell us to re-render marginsDaniel Eklöf2020-09-29-15/+7
|
* render: fix rounding errors when setting initial window size and scale != 1Daniel Eklöf2020-09-17-4/+16
| | | | | | | | | An odd cell width/height sometimes resulted in an odd grid size. Combined with a scaling factor of e.g. 2, that led to a rounding error when converting pixel sizes to logical window sizes. As a result, the _next_ configure event would cause us to loose a pixel, which led to us dropping a row from the grid.
* render: best-effort attempt to set initial window size in chars when scale != 1Daniel Eklöf2020-09-14-6/+7
| | | | | | | | | | | The initial window size is set *before* we’re initially mapped. This means we don’t (yet) know on which output we’ll be mapped. _That_ means we don’t know which scaling factor to use. This implements a best effort attempt, where we use the “guessed” scaling factor. This will always be correct in single-monitor configurations, but may be wrong in multi-monitor setups with different scaling factors.
* render: csd: hide buttons when title bar gets too small to fit themDaniel Eklöf2020-09-10-8/+16
|
* Add -W,--window-size-chars, and foot.ini:initial-window-size-charsDaniel Eklöf2020-09-08-6/+17
| | | | | | | | | | | * Add -W,--window-size-chars command line option * Add initial-window-size-chars foot.ini option * Add -w,--window-size-pixels command line option * Add initial-window-size-pixels foot.ini option * Deprecate -g,--geometry command line option in favor of -w,--window-size-pixels * Deprecate geometry option in foot.ini in favor of initial-window-size-pixels