Phase 9, MA1: crates/ghostty-macos (AppKit via objc2; empty stub on non-Apple targets) ports the foundation of Ghostty 1.3.1's Swift macOS app (ghostty/macos): main, AppDelegate (+Ghostty) with lifecycle, dock menu, open-file, notifications, shortcut sync and quit/reopen paths; MainMenu.xib as generated menu tables built into NSMenus; the Ghostty.App/Config/Surface wrappers driving libghostty in-process via ghostty-lib; the generic helpers; scripts/macos-bundle.sh to assemble Ghostty.app (dry-run on Linux). Feature areas are stubbed for MA2-MA5. Design and type mapping: docs/rewrite/notes/macos-app-design.md (App Intents is a Swift-only framework and cannot be ported). Compile-checked only (no macOS here): just check-macos passes for aarch64/x86_64-apple-darwin with -D warnings; 125 platform-independent tests run on Linux. Test Plan: - just check-macos - cargo test -p ghostty-macos
59 lines
1.9 KiB
Rust
59 lines
1.9 KiB
Rust
//! `Sources/Helpers`: the generic helpers.
|
|
//!
|
|
//! SwiftUI-only helpers have no Rust/AppKit counterpart and are documented as
|
|
//! unportable in `docs/rewrite/notes/macos-app-design.md` (`Backport`,
|
|
//! `HostingWindow`, `NonDraggableHostingView`, `MetalView`, the `View` /
|
|
//! `Transferable` extensions). `Weak<T>` is `std::rc::Weak` / `objc2::rc::Weak`.
|
|
//!
|
|
//! Pure logic (string/color/frame math, counters, decisions) lives in
|
|
//! platform independent modules so it is unit-tested on every target; the
|
|
//! AppKit parts are thin `cfg(target_vendor = "apple")` wrappers around it.
|
|
|
|
#![cfg_attr(test, allow(clippy::unwrap_used))]
|
|
|
|
// Platform independent (tested on every target).
|
|
pub mod any_sort_key;
|
|
pub mod app_info;
|
|
pub mod color;
|
|
pub mod cursor_counter;
|
|
pub mod extensions;
|
|
pub mod fullscreen_logic;
|
|
pub mod geometry;
|
|
pub mod keyboard_shortcut;
|
|
pub mod last_window_position_logic;
|
|
pub mod notification_center;
|
|
pub mod published;
|
|
|
|
// AppKit.
|
|
#[cfg(target_vendor = "apple")]
|
|
pub mod codable_bridge;
|
|
#[cfg(target_vendor = "apple")]
|
|
pub mod cross_kit;
|
|
#[cfg(target_vendor = "apple")]
|
|
pub mod cursor;
|
|
#[cfg(target_vendor = "apple")]
|
|
pub mod dispatch;
|
|
#[cfg(target_vendor = "apple")]
|
|
pub mod expiring_undo_manager;
|
|
#[cfg(target_vendor = "apple")]
|
|
pub mod fullscreen;
|
|
#[cfg(target_vendor = "apple")]
|
|
pub mod keyboard_layout;
|
|
#[cfg(target_vendor = "apple")]
|
|
pub mod last_window_position;
|
|
#[cfg(target_vendor = "apple")]
|
|
pub mod objc_exception_catcher;
|
|
#[cfg(target_vendor = "apple")]
|
|
pub mod private;
|
|
#[cfg(target_vendor = "apple")]
|
|
pub mod vibrant_layer;
|
|
|
|
/// The main thread marker. Every AppKit object is created and used on the main
|
|
/// thread (the Swift app uses `@MainActor` / `DispatchQueue.main`); panics
|
|
/// elsewhere, which is a programming error.
|
|
#[cfg(target_vendor = "apple")]
|
|
#[must_use]
|
|
pub fn main_thread() -> objc2::MainThreadMarker {
|
|
objc2::MainThreadMarker::new().expect("must be called on the main thread")
|
|
}
|