5828 Commits

Author SHA1 Message Date
Charly Delay
96b4ff39a6 Tentative fix for unexpected font-codepoint-map behavior
In particular when configured to replace several ranges with multiple fonts.

Given the following `font-codepoint-map` config:

```
font-codepoint-map=U+0030-U+0039=Monaco       # 0-9
font-codepoint-map=U+0040=mononoki            # @
font-codepoint-map=U+0041-U+005a=Pixel Code   # A-Z
font-codepoint-map=U+0061-U+007a=Victor Mono  # a-z
```

I noticed a couple of unexpected behavior:

1. Codepoint ranges were assigned the wrong font
2. The declaration order had a direct impact on the font assignment
   (seemed to be rotating in some fashion)

If my understanding of the current implementation is correct, for a
given range index `n` in the `MultiArrayList` `CodepointMap.get(…)`
returns the font descriptor at index `len - n - 1`. In other words, it
returns the descriptor symmetrically opposite relative to the middle of
the list.

I've added a couple test cases that I would expect to pass if my
understanding of the expected behavior is correct, verified that they
were broken under the current behavior, and updated the implementation
of `CodepointMap.get(…)` accordingly.

My understanding of the original intent is to give priority to the
latest range match in the list (which is a use case already tested by
the `codepointmap` test, but which I believe happened to pass "by
accident"), so I opted for a reverse traversal of the codepoint list.
2024-10-19 15:51:08 +09:00
Tim Culverhouse
4f1cee8eb9 fix: report correct screen pixel size
Mode 2048 and CSI 14 t are size report control sequences which contain
the text area size in pixels. The text area is defined to be the extents
of the grid (rows and columns). Ghostty calculates the available size
for the text area by setting the available padding, and then filling as
much of the remaining space as possible. However, if there are remainder
pixels these are still reported as part of the text area size.

Pass the cell_size geometry through so that we can always report the
correct value: columns * cell width and rows * cell height.
2024-10-18 22:29:52 -05:00
Mitchell Hashimoto
31b6833ea1 config: change macos-option-as-alt default to left
As suggested: https://github.com/ghostty-org/ghostty/discussions/2363#discussioncomment-10824847

This allows users of non-US keyboard layouts to continue to use the
right option key for input methods, while still being able to use the
the left option key as alt for keybindings.

This is a bit of an experiment to see if this is a good default for
everyone. This is in response to very common confusion of US keyboard
layouts where "alt" doesn't work along with the very common use of
non-US layouts where the right option key is used for input methods.
I think this will strike the right balance for most users.
2024-10-18 14:53:13 -07:00
Mitchell Hashimoto
c90ed29341 cli: skip argv0 and actions when parsing CLI flags
This fixes a regression from #2454. In that PR, we added an error when
positional arguments are detected. I believe that's correct, but we
were silently relying on the previous behavior in the CLI commands.

This commit changes the CLI commands to use a new argsIterator function
that creates an iterator that skips the first argument (argv0). This is
the same behavior that the config parsing does and now uses this shared
logic.

This also makes it so the argsIterator ignores actions (`+things`)
and we document that we expect those to be handled earlier.
2024-10-18 12:59:16 -07:00
Mitchell Hashimoto
be3fc5c04a apprt/gtk: exit if there are CLI errors 2024-10-18 08:26:27 -07:00
Mitchell Hashimoto
463f4afc05 apprt/glfw: exit with invalid CLI args 2024-10-18 08:21:42 -07:00
Mitchell Hashimoto
940a46d41f cli: positional arguments are invalid when parsing configuration 2024-10-18 08:11:11 -07:00
Mitchell Hashimoto
4e25840e08 apprt/gtk: support new config diagnostics API 2024-10-18 08:11:11 -07:00
Mitchell Hashimoto
70c175e2a6 c: remove the config load string API
It was unused and doesn't match our diagnostic API.
2024-10-18 08:11:11 -07:00
Mitchell Hashimoto
a12b33662c config: track the location of CLI argument errors 2024-10-18 08:11:11 -07:00
Mitchell Hashimoto
f24098cbd8 config: show filepath and line numbers for config errors
Fixes #1063
2024-10-18 08:11:11 -07:00
Mitchell Hashimoto
a4e14631ef config: richer diagnostics for errors
Rather than storing a list of errors we now store a list of
"diagnostics." Each diagnostic has a richer set of structured
information, including a message, a key, the location where it occurred.

This lets us show more detailed messages, more human friendly messages, and
also let's us filter by key or location. We don't take advantage of
all of this capability in this initial commit, but we do use every field
for something.
2024-10-18 08:11:11 -07:00
Mitchell Hashimoto
3f1d6eb301 expand explicit error set usage
This continues our work to improve the amount of explicit error sets
we use in the codebase. Explicit error sets make it easier to understand
possible failure scenarios, allow us to use exhaustive matching, create
compiler errors if errors are unexpectedly added or removed, etc.

The goal eventually is 100% coverage but we're not even close yet.
This just moves us a little closer.
2024-10-18 08:10:41 -07:00
Qwerasd
2a4398b319 font/sprite: undercurl minimum thickness improvement 2024-10-17 21:07:52 -04:00
Justin Su
203110355d Fix "external affects" typo in documentation 2024-10-17 14:59:20 -04:00
Rick Calixte
d0316b746d list_fonts and list_keybinds: Fix typos in documentation
test.yml: Switch to Windows Server 2022 and update Zig URL
2024-10-16 22:56:16 -04:00
Mitchell Hashimoto
7b668d3dc1 Merge pull request #2440 from jcollie/window-theme-ghostty-4-16
gtk: use CSS variables and color calcs introduced in 4.16
2024-10-16 06:24:19 -07:00
Mitchell Hashimoto
c614f2b485 apprt/gtk: use stackfallback for runtime CSS, explicit errors 2024-10-16 06:19:47 -07:00
Mitchell Hashimoto
9d341a9fca Merge pull request #2444 from qwerasd205/quicklook-pos
macOS: fix quicklook position
2024-10-15 16:56:08 -07:00
Jeffrey C. Ollie
f645d6962b cli: add GTK & libadwaita version info
If the apprt is GTK add the GTK and the libadwaita version info to the
`+version` action. This information is available in the log but it may
be more accessible here.
2024-10-15 14:48:34 -05:00
Qwerasd
de16541bca macOS: fix quicklook position
Account for padding and properly calculate text baseline, since that is
the position that the NSView `showDefinition` method ultimately needs.
2024-10-15 15:40:15 -04:00
Mitchell Hashimoto
4c18f1bf4b Merge pull request #2439 from qwerasd205/unicode-16-sprite-font
Excise pixman, use z2d for sprite fonts, refactor box drawing, add new box characters
2024-10-15 09:39:04 -07:00
Mitchell Hashimoto
8a38c87d90 font: use explicit error sets where we can 2024-10-15 09:37:51 -07:00
Mitchell Hashimoto
bb2c8e479d font/sprite: clarify log 2024-10-15 09:30:55 -07:00
Qwerasd
c66042d6e0 font/sprite: address PR review feedback
- Make canvas geometry primitives generic, use `Rect(u32)` for `rect`
function, so that we don't have to worry about negatives or rounding.
- Make `Quads` struct packed just in case it gets non-comptime use in
the future.
- Clarify comment on why we're discarding out of range pixels + runtime
unreachable for any other type of error which we shouldn't ever see.
- Move z2d import above in-tree imports.
2024-10-15 12:00:11 -04:00
Mitchell Hashimoto
7673ce31a9 Merge pull request #2441 from ghostty-org/push-sqsmtmrsswxp
macos: NSProcessInfo-based arg iterator so CLI args work
2024-10-14 19:05:03 -07:00
Qwerasd
83a56afcb1 font/sprite: fix weird code 2024-10-14 20:52:42 -04:00
Qwerasd
37144fd5b8 font/sprite: fix light arc character for odd thicknesses
+ update Box.ppm ground truth image
2024-10-14 20:47:04 -04:00
Qwerasd
c0315a04b4 test(font/sprite): add second size to box regression test
Smaller, odd cell size, odd (1) thickness, catches more edge cases with
rounding etc.
2024-10-14 20:31:01 -04:00
Mitchell Hashimoto
115e14f19f macos: NSProcessInfo-based arg iterator
Fixes #2432

On macOS, processes with an NSApplicationMain entrypoint do not have
access to libc argc/argv. Instead, we must use NSProcessInfo. This
commit introduces an args iterator that uses NSProcessInfo, giving us
access to the args.

This also fixes an issue where we were not properly skipping argv0 when
iterating over the args. This happened to be fine because we happened to
ignore invalid args but it introduces a config error.
2024-10-14 17:08:33 -07:00
Jeffrey C. Ollie
ca42b4ca1c gtk: use CSS variables and color calcs introduced in 4.16
This takes advantage of CSS variables and color expressions to improve
the `window-theme=ghostty` support. The only visibile difference from
the previous implementation is that the header bar will darken if the
Ghostty window is in the background, which is standard for GTK apps.

This is conditional at runtime. If Ghostty detects that you're running
against GTK 4.16 or newer it will use the CSS variables and color calcs.
If you're running against older versions it will use CSS classes to
achieve nearly the same effect.
2024-10-14 18:24:05 -05:00
Qwerasd
bb5b7b0274 font/sprite(Box): refactor smooth mosaic rendering
+ un-`comptime` the line spec and make it a packed struct, to reduce
codegen size.
2024-10-14 17:50:49 -04:00
Qwerasd
d38d0f30c4 font/sprite: replace pixman with z2d, extend Box coverage
More complete coverage of the Symbols For Legacy Computing block,
including characters from Unicode 16.0.

Pixman and the web canvas impl for Canvas have been removed in favor of
z2d for drawing, since it has a nicer API with more powerful methods,
and is in Zig with no specific platform optimizations so should compile
to wasm no problem.
2024-10-14 17:50:49 -04:00
Qwerasd
c86b5f44ce font/sprite: refactor box drawing quads/sextants
Move away from C-style bit sets, calculate sextants procedurally rather
than hard coding.
2024-10-14 17:50:49 -04:00
Qwerasd
d63cf6eaec test(font/sprite): generate diff image on failed regression check 2024-10-14 17:50:49 -04:00
Qwerasd
ced4247e55 font/sprite: refactor lines and fractional blocks, add ground truth for regression test
Use a single unified function for intersection-style line drawing chars,
and one for fractional block characters. Add a ground truth image based
on this commit for the regression test (differences from before changes
validated visually, 1 incorrect rendering actually fixed)
2024-10-14 17:50:49 -04:00
Qwerasd
f3e74384bb test(font/sprite): add regression test for box drawing sprites 2024-10-14 17:50:49 -04:00
Qwerasd
74750fbd49 font/Atlas: add dump method to dump to ppm 2024-10-14 17:50:49 -04:00
Qwerasd
2462921681 font/sprite(underline): make undercurl segment symmetrical
Previously was biased half a pixel to one side.
2024-10-14 14:53:09 -04:00
Qwerasd
63f82119cd font/sprite(underline): add thickness correction to undercurl 2024-10-14 14:46:43 -04:00
Mitchell Hashimoto
0cf12cd88b input: make clear the open keybinding uses xdg-open 2024-10-14 09:32:38 -07:00
Mitchell Hashimoto
ccb97c6c33 Merge pull request #2417 from qwerasd205/misc-shaper-fixes
Renderer `rebuildCells` rework
2024-10-12 09:39:08 -07:00
Mitchell Hashimoto
6ce5f3f94b Merge pull request #2434 from ofseed/en-space
renderer: generalize the definition of "space"
2024-10-12 09:37:15 -07:00
Mitchell Hashimoto
862bdcb92a apprt/gtk: adw about dialog introduces in libadw 1.5.0
Fixes #2433
2024-10-12 09:35:09 -07:00
Yi Ming
0571c50d63 renderer: generalize the definition of "space" 2024-10-12 17:56:51 +08:00
Qwerasd
e4f4b708c9 font/shaper: explicitly skip invisible cells while shaping
Fixes a bug caused by the renderer logic assuming this behavior and not
advancing the run iterator when skipping foreground elements in cells
with the invisible flag set.
2024-10-11 13:50:16 -04:00
Mitchell Hashimoto
97abf3c370 font/noop: conform to new run struct type 2024-10-10 17:24:44 -07:00
Mitchell Hashimoto
c26d1cb28e config: add accidentally removed keybinding 2024-10-10 16:47:35 -07:00
Mitchell Hashimoto
745079cbb5 core: simplify scroll math, fix horizontal scroll direction on macOS
This simplifies the math for calculating scroll vectors based on mouse
scroll events. This was done to fix inverted horizontal scrolling on
macOS with natural scrolling enabled. Many assertions were added for
assumptions and our preconditions are clearly documented.

The preconditions are:

  * Apprt scroll offsets are negative down/left, positive up/right
  * Terminal vertical scroll is postive down, negative up (opposite
    since scroll for a terminal means how many rows to move down).
  * `Surface.scrollCallback` is always call with an apprt offset.
  * Apprt is responsible for implementing natural scrolling. Surface
    always assumes negative is down/left.
2024-10-10 16:24:16 -07:00
Mitchell Hashimoto
eec77e271c macos: change our minimum version to macOS 13
macOS 12 is officially EOL by Apple and the project only supports
officially supported versions of macOS. Once publicly released, users on
older macOS versions will have to use older released builds.
2024-10-09 14:41:57 -07:00