// Platform interfaces, ported from gpui/src/platform.rs (the core subset: // windows, event loop, executor dispatcher, cursor and clipboard; text // system, glyph atlas, IME, menus and displays arrive in M9/M10). // // Pure trait definitions only; concrete backends live in `platform/test` // (M7) and `platform/web` (M8). ///| /// A platform-backed window handle (GPUI: `PlatformWindow`). pub(open) trait PlatformWindow { /// Window bounds in logical pixels. fn bounds(Self) -> @geometry.Bounds[@geometry.Pixels] /// Size of the drawable content area in logical pixels. fn content_size(Self) -> @geometry.Size[@geometry.Pixels] /// Device-pixel scale factor. fn scale_factor(Self) -> Double /// Last known pointer position in logical pixels. fn mouse_position(Self) -> @geometry.Point[@geometry.Pixels] /// Currently held modifier keys. fn modifiers(Self) -> @input.Modifiers /// Whether this window is currently active/focused. fn is_active(Self) -> Bool /// Whether the pointer is currently over this window. fn is_hovered(Self) -> Bool /// Sets the window's title. fn set_title(Self, String) -> Unit /// Focuses/brings this window to the front. fn activate(Self) -> Unit /// Programmatically resizes the window to `size`. Must not re-enter /// `on_resize`. fn resize(Self, @geometry.Size[@geometry.Pixels]) -> Unit /// Presents a finished `Scene`. fn draw(Self, @scene.Scene) -> Unit /// Requests that the platform invoke the `on_request_frame` callback on /// the next frame. fn schedule_frame(Self) -> Unit /// App-driven teardown hook (MoonBit has no `Drop`). Must be idempotent /// and must not re-invoke `on_close`. fn close(Self) -> Unit /// Registers the callback invoked when a scheduled frame should draw. fn on_request_frame(Self, () -> Unit) -> Unit /// Registers the callback invoked for platform input events. fn on_input(Self, (@input.PlatformInput) -> @input.DispatchEventResult) -> Unit /// Registers the callback invoked when the window size or scale factor /// changes from the platform side. fn on_resize(Self, (@geometry.Size[@geometry.Pixels], Double) -> Unit) -> Unit /// Registers the callback invoked when active status changes. fn on_active_status_change(Self, (Bool) -> Unit) -> Unit /// Registers the callback invoked when pointer hover status changes. fn on_hover_status_change(Self, (Bool) -> Unit) -> Unit /// Registers the callback asked whether a user-initiated close should /// proceed. fn on_should_close(Self, () -> Bool) -> Unit /// Registers the callback invoked when the platform closes the window. fn on_close(Self, () -> Unit) -> Unit } ///| /// Platform services (GPUI: `Platform`). pub(open) trait Platform { /// The dispatcher used by the app's executors. fn dispatcher(Self) -> &@executor.Dispatcher /// Default logical bounds for a new window when `WindowOptions.window_bounds` /// is `None`. fn default_window_bounds(Self) -> @geometry.Bounds[@geometry.Pixels] /// Opens a new platform window with the given id and parameters. fn open_window(Self, WindowId, WindowParams) -> &PlatformWindow /// Starts the platform event loop, calling `on_finish_launching` once /// ready. fn run(Self, () -> Unit) -> Unit /// Requests that the platform event loop exit. fn quit(Self) -> Unit /// The currently active window id, if any. fn active_window(Self) -> WindowId? /// Sets the pointer cursor style. fn set_cursor_style(Self, @style.CursorStyle) -> Unit /// Reads the current clipboard contents, if any. fn read_from_clipboard(Self) -> ClipboardItem? /// Replaces the clipboard contents. fn write_to_clipboard(Self, ClipboardItem) -> Unit /// Opens `url` in the system/browser handler. fn open_url(Self, String) -> Unit }