132 Commits

Author SHA1 Message Date
Jeffrey C. Ollie
4ad749607a core: performAction now returns a bool
This is to facilitate the `performable:` prefix on keybinds that are
implemented using app runtime actions.
2025-02-11 16:43:50 -08:00
Mitchell Hashimoto
40bdea7335 macos: handle overridden system bindings with no focused window 2025-01-04 14:07:47 -08:00
Mitchell Hashimoto
e8811ac6fb Move app quit to apprt action
This changes quit signaling from a boolean return from core app `tick()`
to an apprt action. This simplifies the API and conceptually makes more
sense to me now.

This wasn't done just for that; this change was also needed so that
macOS can quit cleanly while fixing #4540 since we may no longer trigger
menu items. I wanted to split this out into a separate commit/PR because
it adds complexity making the diff harder to read.
2025-01-04 07:18:53 -08:00
Mitchell Hashimoto
cd49015243 App applies conditional state, supports theme setting
The prior light/dark mode awareness work works on surface-level APIs. As
a result, configurations used at the app-level (such as split divider
colors, inactive split opacity, etc.) are not aware of the current theme
configurations and default to the "light" theme.

This commit adds APIs to specify app-level color scheme changes. This
changes the configuration for the app and sets the default conditional
state to use that new theme. This latter point makes it so that future
surfaces use the correct theme on load rather than requiring some apprt
event loop ticks. Some users have already reported a short "flicker" to
load the correct theme, so this should help alleviate that.
2024-11-22 14:08:35 -08:00
Mitchell Hashimoto
a191f3c396 apprt: switch to reload_config action that calls update_config API 2024-11-22 11:52:34 -08:00
Mitchell Hashimoto
fadfb08efe apprt: add config_change action 2024-11-21 10:30:27 -08:00
Mitchell Hashimoto
a436bd0af6 move datastructures to dedicated "datastruct" package 2024-11-07 14:39:10 -08:00
Mitchell Hashimoto
65f1cefb4e config: add "initial-command" config, "-e" sets that
Fixes #2601

It is more expected behavior that `-e` affects only the first window. By
introducing a dedicated configuration we avoid making `-e` too magical:
its simply syntax sugar for setting the "initial-command" configuration.
2024-11-05 16:58:20 -08: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
463f4afc05 apprt/glfw: exit with invalid CLI args 2024-10-18 08:21:42 -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
Mitchell Hashimoto
8d7367fa64 input: return a K/V entry for the binding set get 2024-10-08 06:29:54 -10:00
Mitchell Hashimoto
494fedca2f apprt/gtk: report proper app focus state 2024-10-06 13:31:03 -07:00
Mitchell Hashimoto
e56cfbdc8b macos: set the proper app focus state 2024-10-06 10:06:17 -10:00
Mitchell Hashimoto
bac1780c3c core: add app focused state, make App.keyEvent focus aware 2024-10-06 09:58:46 -10:00
Mitchell Hashimoto
6785f886ad core: ghostty_app_key only handles global keybinds for now
This introduces a separate bug fixes #2396
2024-10-06 09:32:30 -10:00
Mitchell Hashimoto
f9e6d6efa6 macos: forward key events to the app when no windows exist 2024-10-05 10:05:06 -10:00
Roland Peelen
24ba1a6100 Add action on Zig side 2024-10-02 10:33:36 -07:00
Mitchell Hashimoto
1570ef01a7 rename slide to quick terminal 2024-09-28 15:20:35 -07:00
Mitchell Hashimoto
7806366eec core: fix up toggle_slide_terminal action for rebase 2024-09-27 18:36:06 -07:00
Mitchell Hashimoto
7befb5a418 macos: fix previous/next tab bindings, improve action logging 2024-09-27 12:24:11 -07:00
Mitchell Hashimoto
0e043bc0e4 apprt: transition all hasDecls in App.zig to use the new action dispatch 2024-09-25 11:28:10 -07:00
Mitchell Hashimoto
13603c51a9 apprt: begin transition to making actions an enum and not use hasDecl 2024-09-25 11:02:45 -07:00
Mitchell Hashimoto
1b31663865 apprt/embedded: new_window can be called without a parent 2024-09-24 18:33:10 -07:00
Mitchell Hashimoto
1ad904478d Tap events, core API to handle global keybinds 2024-09-24 16:29:02 -07:00
Mitchell Hashimoto
7f8c1a37ff core: handle app bindings in the App struct 2024-09-23 19:08:23 -07:00
Mitchell Hashimoto
224f2d0491 apprt/gtk: use tagged union for quit timer 2024-08-03 10:05:31 -07:00
Jeffrey C. Ollie
ec0f90d1b6 Improve quit timers.
Instead of "polling" to see if a quit timer has expired, start a single
timer that expires after the confiugred delay when no more surfaces are
open. That timer can be cancelled if necessary.
2024-08-01 14:49:02 -05:00
Jeffrey C. Ollie
7c893881c3 Address review comments
1. Switch to using Wyhash instead of a cryptographic hash.
2. Move global variables to App struct.
2024-05-17 17:13:43 -05:00
Mitchell Hashimoto
2a06cf54ba core: App asserts the font grid set is empty on close 2024-04-05 21:28:50 -07:00
Mitchell Hashimoto
04e0cd29e5 core: begin converting to SharedGridSet, renderers still broken 2024-04-05 15:25:45 -07:00
Mitchell Hashimoto
6d7053a1ad core: convert surface/app to use GroupCacheSet 2024-04-05 09:29:40 -07:00
Borja Clemente
646e3c365c Add settings shortcut on MacOS
- Settings shortcut opens the config file in the default editor.

Signed-off-by: Borja Clemente <borja.clemente@gmail.com>
2023-12-17 16:19:22 +01:00
Mitchell Hashimoto
b021d76edf core: quit-after-last-window-closed works properly with "exit"
Fixes #1085

This moves the logic of exiting when there are no surfaces left fully to
apprt and away from the core.
2023-12-13 16:35:14 -08:00
Mitchell Hashimoto
45a4be6873 core: move resources dir to main global state 2023-11-22 21:12:01 -08:00
kcbanner
232df8de8f windows: add support for the glfw backend on Windows
Changes:
- Add WindowsPty, which uses the ConPTY API to create a pseudo console
- Pty now selects between PosixPty and WindowsPty
- Windows support in Command, including the ability to launch a process with a pseudo console
- Enable Command tests on windows
- Add some environment variable abstractions to handle the missing libc APIs on Windows
- Windows version of ReadThread
2023-11-05 23:15:49 +00:00
Mitchell Hashimoto
5a299e14e4 all threads are notified of inspector state, trigger render 2023-10-24 15:27:15 -07:00
Mitchell Hashimoto
088ae5c454 fix build with no font discovery 2023-10-19 19:43:04 -07:00
Mitchell Hashimoto
678bd0de0c core: surface should not use app mailbox
The surface runs on the same thread as the app so if we use the app
mailbox then we risk filling the queue before it can drain. The surface
should use the app directly.

This commit just changes all the calls to use the app directly. We may
also want to coalesce certain changes to avoid too much CPU but I defer
that to a future change.
2023-09-13 08:34:09 -07:00
Mitchell Hashimoto
56ccadd7f1 core: app needsConfirmQuit to streamline quitting if no active sessions 2023-09-11 15:44:08 -07:00
Mitchell Hashimoto
6a8d302fa0 core: set focused surface pointer to null if matches on delete
We previously never set the focused pointer to null. I thought this
would be fine because a `hasSurface` check would say it doesn't exist.
But I didn't account for the fact that a deleted surface followed very
quickly by a new surface would free the pointer, then the allocation
would reuse the very same pointer, making `hasSurface` return a false
positive.

Well, technically, hasSurface is not wrong, the surface exists, but its
not really the same surface, its just a surface that happens to have the
same pointer as a previously freed surface.

Co-authored-by: Will Pragnell <wpragnell@gmail.com>
2023-08-25 21:01:12 -07:00
Mitchell Hashimoto
0af6edc25b only the app should own the font discovery instance 2023-08-13 11:51:24 -07:00
Mitchell Hashimoto
619d2ade3e only initialize font discovery mechanism once, cache on App
Fontconfig in particular appears unsafe to initialize multiple times.

Font discovery is a singleton object in an application and only ever
accessed from the main thread so we can work around this by only
initializing and caching the font discovery mechanism exactly once on
the app singleton.
2023-08-13 08:01:33 -07:00
Mitchell Hashimoto
bd7cc4b71d core: App looks up resources dir on startup 2023-08-08 09:21:52 -07:00
Mitchell Hashimoto
f31d6fb8fe apprt: clean up how apprt initializes surfaces 2023-05-31 21:08:50 -07:00
Mitchell Hashimoto
553e09eff9 apprt/embedded: new surfaces inherit last focused 2023-05-31 19:12:01 -07:00
Mitchell Hashimoto
a158813a3d app keeps track of last focused surface 2023-05-31 18:59:40 -07:00
Mitchell Hashimoto
f36a35ecc9 core: quit flag is reset after tick 2023-03-27 10:10:06 -07:00
Mitchell Hashimoto
3689f1fe39 apprt/gtk: only show exit confirmation if process is alive 2023-03-25 16:36:12 -07:00
Mitchell Hashimoto
f5c1dfa374 reload_config keybinding (defaults to ctrl+alt+super+space) 2023-03-19 09:50:53 -07:00