namespace XFESystem.Desktop; public sealed class DesktopWindow { public int Id { get; internal set; } public DesktopApplication Application { get; internal set; } public DesktopBounds Bounds { get; internal set; } public DesktopBounds RestoreBounds { get; internal set; } public bool IsMinimized { get; internal set; } public bool IsMaximized { get; internal set; } public bool IsSnapped { get; internal set; } public DesktopChromeAnimation ChromeAnimation { get; } = new(); public string Title { get; internal set; } = ""; public string Location { get; internal set; } = ""; public string Content { get; internal set; } = ""; public string Status { get; internal set; } = ""; public bool IsDirty { get; internal set; } public int Caret { get; internal set; } public int ScrollLine { get; internal set; } public XFESystem.Console.TerminalSnapshot? Terminal { get; internal set; } public TerminalShell? Shell { get; internal set; } public bool TerminalProgramRunning { get; internal set; } internal int TerminalScrollRows { get; set; } internal int TerminalInputStart { get; set; } internal long TerminalCaretStarted { get; set; } internal bool TerminalCaretVisible { get; set; } = true; public IInteractiveBrowserSession? BrowserSession { get; internal set; } /// A separate web document owner; it never shares the editor's model, scroll offset or input focus. public IInteractiveBrowserSession? PreviewSession { get; internal set; } public MarkdownViewMode MarkdownView { get; internal set; } = MarkdownViewMode.Edit; public bool IsMarkdown => Application == DesktopApplication.Editor && Location.EndsWith(".md", StringComparison.OrdinalIgnoreCase); public bool IsPreviewPreparing => PreviewPreparation is not null; internal IEditorPreparationOperation? PreviewPreparation { get; set; } internal long PreviewPreparationGeneration { get; set; } internal string? PreviewSource { get; set; } internal string? PreviewObservedContent { get; set; } internal string? PreviewError { get; set; } internal long PreviewRefreshAt { get; set; } internal bool PreviewFocused { get; set; } internal double PreviewScroll { get; set; } public bool IsEditorPreparing => EditorPreparation is not null; public long EditorPreparationGeneration { get; internal set; } internal IEditorPreparationOperation? EditorPreparation { get; set; } internal long EditorPreparationStarted { get; set; } internal long EditorSourcePresentedGeneration { get; set; } internal long EditorInputVersion { get; set; } internal bool BrowserContentFocused { get; set; } internal double BrowserScroll { get; set; } internal int HorizontalScroll { get; set; } internal bool AddressSelected { get; set; } // Selection ends with the first character; editing continues until an // explicit submit/cancel, independently of worker page snapshot delivery. internal bool AddressEditing { get; set; } internal string? CommittedBrowserAddress { get; set; } internal string? MeasuredContent { get; set; } internal int MeasuredHorizontalScroll { get; set; } internal int MeasuredViewportWidth { get; set; } internal int MeasuredContentWidth { get; set; } internal int AppearanceFocus { get; set; } internal int AppearancePreset { get; set; } internal string AppearanceAccentText { get; set; } = ""; internal bool AppearanceAccentSelected { get; set; } } public enum MarkdownViewMode { Preview, Edit, Split } public readonly record struct BrowserPage(string Address, string Title, string Text); /// A real document/JS engine must be supplied by the runtime adapter. public interface IBrowserService { BrowserPage Navigate(string address); string ExecuteJavaScript(string source); string PreviewMarkdown(string markdown); } /// Local code previews must receive a fresh environment, without a previously visited page's DOM. public interface IJavaScriptPreviewService : IBrowserService { string PreviewJavaScript(string source); }