Files
gui/macos/DModem/DModemApp.swift
Claude f62777b994 Windows and macOS apps, the app icon, and terminal fixes
- windows/: the Windows app in plain Win32 C++ (ANSI APIs, Win95
  common controls, Winsock 1.1), so that it runs on Windows 95 and
  later: Modem, Terminal, Settings, Call Stats and Log pages over
  libdmodemctl.  dmodemd is started where Windows can run it; on 9x
  the app reaches a modem over TCP or a COM port.  build-watcom.sh
  builds it with Open Watcom; CMake builds it with MinGW or MSVC.
- macos/: the SwiftUI app (XcodeGen project), with the terminal drawn
  from libdmodemctl's screen, the SIP password in the keychain.
- The app icon (assets/dmodem.svg, from the brand's jack art) as .ico
  and an asset catalogue, by tools/icons.js and tools/icons.py.
- libdmodemctl: anonymous enums (Swift imports them as constants),
  Backspace as BS (the modem's S5), key table without designated
  initialisers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRVTPinTtLUajudobBC
2026-11-06 13:53:21 +00:00

52 lines
1.5 KiB
Swift

// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2026, D-Modem
//
// DModemApp.swift - the app: its window, menus and the line settings
import SwiftUI
@main
struct DModemApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) var delegate
@StateObject private var modem = Modem()
var body: some Scene {
Window("D-Modem", id: "main") {
ContentView()
.environmentObject(modem)
.frame(minWidth: 760, minHeight: 520)
.onAppear { delegate.modem = modem }
}
.commands {
CommandMenu("Modem") {
Button(modem.running ? "Stop" : "Start") {
modem.running ? modem.stop() : modem.start()
}
.keyboardShortcut("r")
Divider()
Button("Answer") { modem.answer() }
.disabled(modem.state != Int(DMC_RINGING))
Button("Hang Up") { modem.hangUp() }
.keyboardShortcut(".")
.disabled(!modem.canHangUp)
}
}
Settings {
LineSettingsView()
.environmentObject(modem)
}
}
}
final class AppDelegate: NSObject, NSApplicationDelegate {
weak var modem: Modem?
func applicationShouldTerminateAfterLastWindowClosed(_ app: NSApplication) -> Bool {
true
}
func applicationWillTerminate(_ notification: Notification) {
modem?.stop()
}
}