1906 Commits

Author SHA1 Message Date
Mitchell Hashimoto
17d1626e57 Merge pull request #178 from mitchellh/font-integer
Change font metrics to all be integers, not floats.
2023-07-03 11:33:09 -07:00
Mitchell Hashimoto
0faf6097d0 Change font metrics to all be integers, not floats.
Font metrics realistically should be integral. Cell widths, cell
heights, etc. do not make sense to be floats, since our grid is
integral. There is no such thing as a "half cell" (or any point).

The reason we historically had these all as f32 is simplicity mixed
with history. OpenGL APIs and shaders all use f32 for their values, we
originally only supported OpenGL, and all the font rendering used to be
directly in the renderer code (like... a year+ ago).

When we refactored the font metrics calculation to its own system and
also added additional renderers like Metal (which use f64, not f32), we
never updated anything. We just kept metrics as f32 and casted
everywhere.

With CoreText and #177 this finally reared its ugly head. By forgetting
a simple rounding on cell metric calculation, our integral renderers
(sprite fonts) were off by 1 pixel compared to the GPU renderers.
Insidious.

Let's represent font metrics with the types that actually make sense: a
cell width/height, etc. is _integral_. When we get to the GPU, we now
cast to floats. We also cast to floats whenever we're doing more precise
math (i.e. mouse offset calculation). In this case, we're only
converting to floats from a integral type which is going to be much
safer and less prone to uncertain rounding than converting to an int
from a float type.

Fixes #177
2023-07-03 11:23:20 -07:00
Mitchell Hashimoto
5e1b4aa40f fix old zig fmt in blocks.zig 2023-07-03 08:39:35 -07:00
Mitchell Hashimoto
57e109f8b4 Merge pull request #176 from mitchellh/mrn/gtk-fullscreen
gtk: handle ctrl+return to toggle fullscreen
2023-07-02 21:54:45 -07:00
Thorsten Ball
567ba5a25e gtk: handle ctrl+return to toggle fullscreen
This is a follow-up to #172 and adds fullscreen handling to the GTK
apprt.

Works reliably for the current window and mimics exactly what happens
when F11 is pressed, which seems to be the standard keybinding for GTK
apps to toggle fullscreen.
2023-07-03 06:38:14 +02:00
Mitchell Hashimoto
8ca9e14d89 adjust mouse selection calculation for window-padding settings
Fixes #170
2023-07-02 12:45:06 -07:00
Mitchell Hashimoto
84550f276a macos: make close the terminal button non-destructive
So that "return" works.
2023-07-02 12:38:16 -07:00
Mitchell Hashimoto
0295feef36 Merge pull request #172 from mitchellh/mrn/toggle-fullscreen
Toggle fullscreen on super/ctrl+return, only macOS for now
2023-07-02 12:00:55 -07:00
Mitchell Hashimoto
2c2bea716f Merge pull request #173 from mitchellh/mrn/readme-colors
README: show how to set color palette in config
2023-07-02 12:00:41 -07:00
Thorsten Ball
82f7ca149d README: show how to set color palette in config
This just popped into my head. Took me a while to figure out the syntax
a few weeks back, so why not document it here? I don't think it'll
change.

I can change the colors though. What I have here is my gruvbox theme.
Maybe we should use the default colors?
2023-07-02 20:27:37 +02:00
Thorsten Ball
8e464db049 Toggle fullscreen on super/ctrl+return, only macOS for now
This fixes or at least is the first step towards #171:

- it adds `cmd/super + return` as the default keybinding to toggle
  fullscreen for currently focused window.
- it adds a keybinding handler to the embedded apprt and then changes
  the macOS app to handle the keybinding by toggling currently focused
  window.
2023-07-02 20:23:49 +02:00
Mitchell Hashimoto
ce77002198 remove metal workaround completely 2023-07-01 15:19:13 -07:00
Mitchell Hashimoto
9968128da9 fix failing test on non-Mac 2023-07-01 15:17:50 -07:00
Mitchell Hashimoto
f537d7aab1 renderer: remove metal workaround, this caused crashes on x86_64
And it now works.
2023-07-01 15:14:24 -07:00
Mitchell Hashimoto
1d1b868958 font: do not use Noto on macOS for tests, it doesn't work 2023-07-01 13:51:31 -07:00
Mitchell Hashimoto
0a718ec3eb pkg/macos: do not use bitCast through a function
workaround Zig issue: https://github.com/ziglang/zig/issues/16290
2023-07-01 13:38:10 -07:00
Mitchell Hashimoto
1dd6e6f29d Merge pull request #165 from mitchellh/coretext
CoreText Rasterizer
2023-07-01 10:17:12 -07:00
Mitchell Hashimoto
06f63288c8 coretext: address TODO 2023-07-01 10:15:50 -07:00
Mitchell Hashimoto
126817cac2 coretext: tweak underline position 2023-07-01 10:12:29 -07:00
Mitchell Hashimoto
51e42a62ed font: default rasterizer on macOS is now coretext 2023-07-01 10:04:49 -07:00
Mitchell Hashimoto
0bb2d22052 renderer: hook up font thickening setting 2023-07-01 10:01:40 -07:00
Mitchell Hashimoto
3795cd6c2d font: turn rasterization options into a struct, add thicken 2023-07-01 09:55:19 -07:00
Mitchell Hashimoto
e99376cac1 font: update comment 2023-07-01 09:23:41 -07:00
Mitchell Hashimoto
b5cc37e20c font: comment out debug logs 2023-07-01 09:23:40 -07:00
Mitchell Hashimoto
42cc11e32c coretext: remove the old renderGlyph impl 2023-07-01 09:23:40 -07:00
Mitchell Hashimoto
3c5be0726f sprite: all rasterized sprites should have a 1px padding 2023-07-01 09:23:40 -07:00
Mitchell Hashimoto
362eeac74b coretext: do not treat color diffs special for offset 2023-07-01 09:23:40 -07:00
Mitchell Hashimoto
d39e3f5428 coretext: improved baseline calculation 2023-07-01 09:23:40 -07:00
Mitchell Hashimoto
69396b0853 coretext: layout rect must fit all chars 2023-07-01 09:23:40 -07:00
Mitchell Hashimoto
5706770c38 coretext: handle glyph padding in region reservation 2023-07-01 09:23:40 -07:00
Mitchell Hashimoto
55254acaad coretext: fix emoji placement 2023-07-01 09:23:40 -07:00
Mitchell Hashimoto
c52dc229f3 coretext: validate atlas depth matches color depth 2023-07-01 09:23:40 -07:00
Mitchell Hashimoto
a74e49833b coretext: colored glyph rendering 2023-07-01 09:23:40 -07:00
Mitchell Hashimoto
286944cd43 cleaning up rasterization, comments 2023-07-01 09:23:39 -07:00
Mitchell Hashimoto
552a1b51d0 coretext: rasterization looking cleaner 2023-07-01 09:23:39 -07:00
Mitchell Hashimoto
079fe7bc94 coretext: the size needs to be in pixels! (see comment) 2023-07-01 09:23:39 -07:00
Mitchell Hashimoto
4d7a2c9f05 font: remove the old comment about not doing the grey stroke 2023-07-01 09:23:39 -07:00
Mitchell Hashimoto
45da58188c fix up for new zig 2023-07-01 09:23:39 -07:00
Mitchell Hashimoto
ef5d86ffb0 coretext: initially fill grey 2023-07-01 09:23:39 -07:00
Mitchell Hashimoto
2a1cbb4f21 coretext: calculate units per em/point 2023-07-01 09:23:39 -07:00
Mitchell Hashimoto
a3401d9690 log if a configured font is not found 2023-07-01 09:23:39 -07:00
Mitchell Hashimoto
20ab117b36 Merge pull request #169 from mitchellh/mrn/goto-tab-macos
macOS: implement cmd+[0-9] to goto tab
2023-07-01 09:21:33 -07:00
Mitchell Hashimoto
eebcbb6955 macos: attach gotoTab listener to contentView and filter on focused win 2023-07-01 09:19:38 -07:00
Thorsten Ball
6ff3f62e3a macOS: implement cmd+[0-9] to goto tab
This is my attempt at fixing #63. It works! But:

1. The `NotificationCenter` subscription is triggered once for every
   open tab. That's obviously wrong. But I'm not sure and could use some
   pointers where else to put the subscription. That leads me to...
2. I'm _not_ knowledgable in Swift/AppKit/SwiftUI, so I might have put
   the wrong/right things in the wrong/right places. For example: wasn't
   sure what's to be handled in Swift and what's to be handled by the
   core in Zig.

Would love some pointers :)
2023-07-01 09:08:02 -07:00
Mitchell Hashimoto
cb775b5d56 Merge pull request #168 from mitchellh/mrn/quit-dialog-return-simple
macOS: change quit dialog to handle return by removing role
2023-07-01 09:04:02 -07:00
Mitchell Hashimoto
64fa064e29 Merge pull request #167 from mitchellh/evanphx/b-precision-mouse-event
Use the precision calculation to determine when to send mouse events
2023-07-01 09:03:31 -07:00
Evan Phoenix
4d46229652 Use the precision calculation to determine when to send mouse events 2023-07-01 15:22:03 +02:00
Thorsten Ball
eea37033bf macOS: change quit dialog to handle return by removing role
This is, as it turns out, the simple version of #166.

It changes the quit dialog to handle return by removing the
`.destructive` role from the `Quit` button.

When that role is set, the `keyboardShortcut(.defaultAction)` doesn't have an effect.

With the role removed, the dialog handles the return key to quit the
application

As I wrote in #166, I can understand if you don't want this change, but
I personally think it's nice to be able to only use the keyboard. iTerm2
also handles return like this in the "Are you sure?" dialog.
2023-07-01 14:52:27 +02:00
Mitchell Hashimoto
a212d811e7 build: update min required zig version 2023-06-30 13:24:01 -07:00
Mitchell Hashimoto
314f9287b1 Update Zig (#164)
* update zig

* pkg/fontconfig: clean up @as

* pkg/freetype,harfbuzz: clean up @as

* pkg/imgui: clean up @as

* pkg/macos: clean up @as

* pkg/pixman,utf8proc: clean up @as

* clean up @as

* lots more @as cleanup

* undo flatpak changes

* clean up @as
2023-06-30 12:15:31 -07:00