343 Commits

Author SHA1 Message Date
Mitchell Hashimoto
75255780e9 renderer/metal: show selections 2024-03-22 20:27:55 -07:00
Mitchell Hashimoto
ff0e07a907 renderer/metal: re-enable the cursor, it works 2024-03-22 20:27:52 -07:00
Mitchell Hashimoto
c61de49082 renderer/metal: port 2024-03-22 20:27:44 -07:00
Mitchell Hashimoto
b48d24a546 update zig 2024-03-13 09:14:12 -07:00
Qwerasd
e8460fa2c2 fix(renderer): allocate enough room for fg cells
Previously encountered OOB when screen filled with cells with glyphs,
underlines, and strikethroughs. Also clarified comment slightly.
2024-03-03 20:26:51 -05:00
Jeffrey C. Ollie
18005ffa35 Fix shader time uniforms (#1462)
* fix shader time uniforms

* renderer/metal: one typo

---------

Co-authored-by: Mitchell Hashimoto <mitchell.hashimoto@gmail.com>
2024-02-04 20:50:07 -08:00
Mitchell Hashimoto
7b3deb13d8 renderer/metal: apply layerContentsPlacement on macOS to fix stretching
Fixes #42
2024-02-02 08:39:08 -08:00
Mitchell Hashimoto
6de4533afb core: handle mouse capture events with link highlighting
Fixes #1416

At a high level, the issue is that when mouse capture is enabled (i.e. in
neovim), "shift" escapes the capture. So "cmd+shift" is equal to "cmd"
which doesn't get sent to the TUI program and so on. For link
highlighting which now requires "cmd" (super) is held, we were sending
"cmd+shift" to the renderer so we weren't checking for links.

So the core of this commit is respecting this scenario and stripping the
shift modifier.

This commit also found that when the mouse wasn't over a link, we were
always checking and highlighting links on line one of the visible
screen. This bug is fixed and should also result in a very slight
performance improvement on rendering in all cases.
2024-02-01 09:19:39 -08:00
Leaf Garland
d1d7665510 Default to background color for cursor-text
Previously the default was black which doesn't work so well if the
cursor block is dark.
2024-01-28 20:20:40 +13:00
Mitchell Hashimoto
ae11cc9042 add a new highlight state that requires modifiers 2024-01-27 19:03:03 -08:00
Mitchell Hashimoto
aa147413c7 renderer/metal: only set shared texture mode on aarch64
This setting is only supported on aarch64.
2024-01-23 14:09:48 -08:00
jcalabro
bc972a4c44 set the atlas texture memory storage mode to shared 2024-01-22 21:24:03 -05:00
Mitchell Hashimoto
7c8b156960 kitty images: support pngs with greyscale/alpha (bpp=2)
Fixes #1355
2024-01-22 14:32:27 -08:00
Mitchell Hashimoto
344c2db097 renderer/metal: initialize layer in init, handle iOS layer 2024-01-18 18:51:01 -08:00
Mitchell Hashimoto
95f729a5fc renderer/metal: only set wantsLayer for AppKit 2024-01-18 15:36:06 -08:00
Mitchell Hashimoto
26e6e8cec8 apprt/embedded: add iOS platform with uivew 2024-01-18 15:03:03 -08:00
Mitchell Hashimoto
01afa293c8 apprt/embedded: fix initialization on macOS 2024-01-18 08:55:03 -08:00
Mitchell Hashimoto
90ea950d71 renderer/metal: use a semaphore to protect deinit while waiting for GPU 2024-01-16 12:18:55 -08:00
Mitchell Hashimoto
c28f2e36cc renderer/metal: do not be unhealthy by default :) 2024-01-16 11:28:01 -08:00
Mitchell Hashimoto
376345dcae macos: detect renderer health failures and show error view 2024-01-16 11:27:18 -08:00
Mitchell Hashimoto
0277a0fb4c renderer/metal: detect frame commit failures and notify surface 2024-01-16 10:51:36 -08:00
Mitchell Hashimoto
96d33fef20 custom shader animation can be set to "always" to always remain active
Fixes #1225

The `custom-shader-animation` configuration can now be set to "always"
which keeps animation active even if the terminal is unfocused.
2024-01-09 09:21:15 -08:00
Mitchell Hashimoto
f447e6f9df font: insert blank cells for multi-cell ligatures for styling
Up to this point, every font I've experienced with ligatures has
replaced the codepoints that were replaced for combining with a space.
For example, if a font has a ligature for "!=" to turn it into a glyph,
it'd shape to `[not equal glyph, space]`, so it'd still take up two
cells, allowing us to style both.

Monaspace, however, does not do this. It turns "!=" into `[not equal
glyph]` so styles like backgrounds, underlines, etc. were not extending.

This commit detects multi-cell glyphs and inserts synthetic blank cells
so that styling returns. I decided to do this via synthetic blank cells
instead of introducing a `cell_width` to the shaper result because this
simplifies the renderers to assume each shaper cell is one cell. We can
change this later if we need to.

Annoyingly, this does make the shaper slightly slower for EVERYONE to
accomodate one known font that behaves this way. I haven't benchmarked
it but my belief is that the performance impact will be negligible
because to figure out cell width we're only accessing subsequent cells
so they're likely to be in the CPU cache and also 99% of cells are going
to be width 1.
2024-01-06 19:22:25 -08:00
Mitchell Hashimoto
be176bb8bd renderer: reload background, foreground, cursor-color at runtime
Fixes #1212
2024-01-04 21:47:12 -08:00
Mitchell Hashimoto
98237b112f config: RepeatableString is null-terminated now
This makes it easier for these values to interface with C APIs
2024-01-03 09:24:15 -08:00
Gregory Anders
060bdff117 terminal: track palette color in cell state
Rather than immediately converting a color palette index into an RGB
value for a cell color, when a palette color is used track the palette
color directly in the cell state and convert to an RGB value in the
renderer.

This causes palette color changes to take effect immediately instead of
only for newly drawn cells.
2024-01-02 22:34:06 -06:00
Mitchell Hashimoto
231a2b6369 renderer/opengl: implement fg_constrained 2023-12-16 20:11:37 -08:00
Mitchell Hashimoto
0b658c8217 renderer/metal: constrain PUA glyphs if they aren't next to space 2023-12-16 20:07:25 -08:00
Mitchell Hashimoto
489ed57e2f font/harfbuzz: track x/y offsets 2023-12-11 21:41:13 -08:00
Mitchell Hashimoto
5e9ddb5e65 renderer/metal: offset zero-advance glyphs by the cell width 2023-12-10 17:08:32 -08:00
Mitchell Hashimoto
0b60ae0010 renderer/metal,opengl: replace matching image IDs if transmit time differs
Fixes #1037

Renderers must convert the internal Kitty graphics state to a GPU
texture for rendering. For performance reasons, renderers cache the GPU
state by image ID. Unfortunately, this meant that if an image was
replaced with the same ID and was already cached, it would never be
updated on the GPU.

This PR adds the transmission time to the cache. If the transmission
time differs, we assume the image changed and replace the image.
2023-12-10 09:16:10 -08:00
Mitchell Hashimoto
56c6c096fa renderer: handle scenarios the preedit text is wider than our screen 2023-12-03 20:16:49 -08:00
Mitchell Hashimoto
0cdefe8b8b core: remove size limit on preedit length by heap allocating
Fixes #882

We previously had a hardcoded limit of 16 codepoints. In #882, a user
pointed out that in Chinese, is reasonable for a preedit input to be
longer than this.

To avoid any future issues, this commit moves to a heap-allocated
variant. Preedits aren't that common, they aren't high throughput, and
they're generally pretty small, so using a heap allocation is fine. The
memory is owned by the person who set it.
2023-12-03 19:54:26 -08:00
Mitchell Hashimoto
7f40881747 font: faces use primary grid metrics to better line up glyphs
Fixes #895

Every loaded font face calculates metrics for itself. One of the
important metrics is the baseline to "sit" the glyph on top of. Prior to
this commit, each rasterized glyph would sit on its own calculated
baseline. However, this leads to off-center rendering when the font
being rasterized isn't the font that defines the terminal grid.

This commit passes in the font metrics for the font defining the
terminal grid to all font rasterization requests. This can then be used
by non-primary fonts to sit the glyph according to the primary grid.
2023-12-02 09:51:15 -08:00
Mitchell Hashimoto
7af4009f27 renderer/metal: minimum contrast ratio is configurable 2023-12-01 21:24:38 -08:00
Mitchell Hashimoto
6c859cca82 renderer/metal: minimum contrast experiment
This uses WCAG2 algorithms with a minimum ratio hardcoded of 3:1. This
is not shippable in its current state because we want the ratio to be
configurable and I'm not happy with the way data is being sent to the
shader.
2023-12-01 20:51:16 -08:00
Mitchell Hashimoto
8fcf3f08dd core: send mouse hover point 2023-11-29 15:30:22 -08:00
Mitchell Hashimoto
5a7596e1b1 renderer: link set for more efficient matching 2023-11-29 15:30:22 -08:00
Mitchell Hashimoto
aa86031ff6 terminal: move line searching here, unit test 2023-11-29 15:30:22 -08:00
Mitchell Hashimoto
5db002cb12 renderer/metal: underline urls 2023-11-29 15:30:21 -08:00
Mitchell Hashimoto
cf8a0bdaec renderer: handle Kitty images where z < 0 for all placements 2023-11-20 21:34:17 -08:00
Mitchell Hashimoto
9988dedb80 renderr/opengl: stylistic 2023-11-20 09:45:38 -08:00
Mitchell Hashimoto
e55cb274ba config: custom-shader-animation 2023-11-17 21:51:07 -08:00
Mitchell Hashimoto
4742cd308d renderer: animation timer if we have custom shaders 2023-11-17 21:50:53 -08:00
Mitchell Hashimoto
244e7266a1 renderer/metal: don't recreate custom shader resources per frame 2023-11-17 21:50:53 -08:00
Mitchell Hashimoto
d3bc1ab6da renderer/metal: reuse an intermediate texture for custom shaders 2023-11-17 21:50:53 -08:00
Mitchell Hashimoto
01a73994cb renderer/metal: setup sampler state 2023-11-17 21:50:53 -08:00
Mitchell Hashimoto
1e572fb10b renderer/metal: load custom shaders 2023-11-17 21:50:52 -08:00
Mitchell Hashimoto
c347148fd7 renderer/metal: CRT effect, ugly hacky code 2023-11-17 21:50:34 -08:00
Mitchell Hashimoto
3095dce685 renderer/metal: wip for loading custom shader pipelines 2023-11-17 21:50:34 -08:00