192 Commits

Author SHA1 Message Date
Mitchell Hashimoto
f7714a113d renderer/opengl: fix compilation 2024-04-28 09:40:03 -07:00
Mitchell Hashimoto
4398896905 renderer/opengl: strikethrough as sprite 2024-04-22 10:30:27 -07:00
Mitchell Hashimoto
06df9b7867 font: remove old files 2024-04-06 20:10:57 -07:00
Mitchell Hashimoto
e3402cef4d address many fontmem todos 2024-04-06 20:00:22 -07:00
Mitchell Hashimoto
3b0b9c2cfd renderer/opengl: set the font grid 2024-04-06 19:55:00 -07:00
Mitchell Hashimoto
3afeac99e9 renderer/opengl: support font size change 2024-04-06 19:35:56 -07:00
Mitchell Hashimoto
a22ca8e4c1 renderer/opengl: clean up texture sync 2024-04-06 09:34:34 -07:00
Mitchell Hashimoto
45f518851d renderer/opengl: convert to SharedGrid, new windows/tabs are frozen 2024-04-05 22:00:51 -07:00
Mitchell Hashimoto
fd9280429e renderer: re-enable URL underlining 2024-03-22 20:28:05 -07:00
Mitchell Hashimoto
d1faa37b65 renderer/opengl: convert 2024-03-22 20:28:01 -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
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
3efe88c85c input: add link highlight always/hover w/ mods 2024-01-27 19:07:49 -08: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
df09c21103 apprt/embedded: compile for Linux 2024-01-18 08:44:56 -08:00
Mitchell Hashimoto
adb7958f61 remove tracy usage from all files 2024-01-13 15:06:08 -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
a8419754b9 renderer/opengl: allow OpenGL 4.1/4.2 2023-12-18 13:59:33 -08:00
Mitchell Hashimoto
4ba44fb8c1 renderer/opengl: error if OpenGL version is too old
This returns an error from the renderer implementation. This error just
crashes Ghostty currently with a stack trace. We can handle the error
later but for now it makes it a lot more obvious why certain error
scenarios happen.
2023-12-18 12:51:53 -08:00
Mitchell Hashimoto
231a2b6369 renderer/opengl: implement fg_constrained 2023-12-16 20:11:37 -08:00
Mitchell Hashimoto
5b4232b094 renderer/opengl: acquire lock to prep kitty images
Fixes #1101

GTK forces all GLArea drawing to happen on the GUI thread. In this
scenario, `updateFrame` and `drawFrame` could be happening in parallel.
This commit grabs the lock while updating the Kitty image protocol state
since that is used by both functions.

We already have a mutex called "draw_mutex" that we hold while we're
modifying data that could be shared by this separate draw thread. We
should reuse that here.
2023-12-15 14:15:32 -08:00
Mitchell Hashimoto
bcf6753c68 renderer/opengl: use new glyph offsets 2023-12-11 21:47:03 -08:00
Mitchell Hashimoto
3e9a6e4de5 renderer/opengl: apply extra offset for zero-advance glyphs 2023-12-10 17:10:00 -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
ec8f3d036e renderer/opengl: implement min contrast 2023-12-01 21:55:51 -08:00
Mitchell Hashimoto
bb60d2c1c0 renderer/opengl: urls 2023-11-29 15:30:23 -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
2a10af90a3 renderer/opengl: draw images 2023-11-19 22:43:39 -08:00
Mitchell Hashimoto
64cacce1cf renderer/opengl: setup image uniforms 2023-11-19 22:33:06 -08:00
Mitchell Hashimoto
76c76ce85e renderer/opengl: upload kitty image textures 2023-11-19 22:08:07 -08:00
Mitchell Hashimoto
e55cb274ba config: custom-shader-animation 2023-11-17 21:51:07 -08:00
Mitchell Hashimoto
61f10dc583 renderer/opengl: new gpucell 2023-11-17 21:51:07 -08:00
Mitchell Hashimoto
8253fc1f31 renderer/opengl: shaders only need one color input 2023-11-17 21:51:07 -08:00
Mitchell Hashimoto
2db36646ac renderer/opengl: some comments 2023-11-17 21:51:07 -08:00
Mitchell Hashimoto
39e7055853 renderer/opengl: enable animations 2023-11-17 21:51:06 -08:00
Mitchell Hashimoto
c8a51a2158 renderer/opengl: create the screen texture 2023-11-17 21:51:06 -08:00
Mitchell Hashimoto
fbc13d08b0 renderer/opengl: set resolution uniform on screen size change 2023-11-17 21:51:06 -08:00
Mitchell Hashimoto
2559d6b367 renderer/opengl: increment time uniform 2023-11-17 21:51:06 -08:00
Mitchell Hashimoto
e0afa442c4 renderer/opengl: better organization of custom shader state 2023-11-17 21:51:06 -08:00
Mitchell Hashimoto
47971e7663 renderer/opengl: setup uniform buffer objects for custom shaders 2023-11-17 21:51:06 -08:00
Mitchell Hashimoto
5fc91401f2 renderer/opengl: draw custom shaders, simplified 2023-11-17 21:51:06 -08:00