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
57 lines
1.6 KiB
Rust
57 lines
1.6 KiB
Rust
//! `Sources/Features/Settings` (owner: MA4).
|
|
//!
|
|
//! MA1 provides the `ConfigurationErrorsController` surface that
|
|
//! `AppDelegate.ghosttyConfigDidChange` drives. TODO(MA4): the window
|
|
//! (ConfigurationErrors.xib + SwiftUI view), SettingsView.
|
|
|
|
use std::cell::RefCell;
|
|
|
|
/// `ConfigurationErrorsController.sharedInstance` (data model only).
|
|
#[derive(Default)]
|
|
pub struct ConfigurationErrorsController {
|
|
errors: RefCell<Vec<String>>,
|
|
window_visible: std::cell::Cell<bool>,
|
|
}
|
|
|
|
thread_local! {
|
|
static SHARED: std::rc::Rc<ConfigurationErrorsController> = std::rc::Rc::default();
|
|
}
|
|
|
|
impl ConfigurationErrorsController {
|
|
/// `sharedInstance`.
|
|
#[must_use]
|
|
pub fn shared_instance() -> std::rc::Rc<Self> {
|
|
SHARED.with(std::rc::Rc::clone)
|
|
}
|
|
|
|
/// `errors` getter.
|
|
#[must_use]
|
|
pub fn errors(&self) -> Vec<String> {
|
|
self.errors.borrow().clone()
|
|
}
|
|
|
|
/// `errors` setter: with no errors the window closes (`didSet`).
|
|
pub fn set_errors(&self, errors: Vec<String>) {
|
|
let empty = errors.is_empty();
|
|
*self.errors.borrow_mut() = errors;
|
|
if empty {
|
|
self.window_visible.set(false);
|
|
}
|
|
}
|
|
|
|
/// `window == nil || !window!.isVisible`.
|
|
#[must_use]
|
|
pub fn is_window_visible(&self) -> bool {
|
|
self.window_visible.get()
|
|
}
|
|
|
|
/// `showWindow(_:)`. TODO(MA4)
|
|
pub fn show_window(&self) {
|
|
log::warn!(
|
|
"TODO(MA4): ConfigurationErrorsController.showWindow ({} errors)",
|
|
self.errors.borrow().len()
|
|
);
|
|
self.window_visible.set(true);
|
|
}
|
|
}
|