XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFESystem

【Rust】XFE系统,基于Rust和汇编

公开
关注 0 Fork 0 Star 0
UTF-8
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; }
    /// <summary>A separate web document owner; it never shares the editor's model, scroll offset or input focus.</summary>
    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);

/// <summary>A real document/JS engine must be supplied by the runtime adapter.</summary>
public interface IBrowserService
{
    BrowserPage Navigate(string address);
    string ExecuteJavaScript(string source);
    string PreviewMarkdown(string markdown);
}

/// <summary>Local code previews must receive a fresh environment, without a previously visited page's DOM.</summary>
public interface IJavaScriptPreviewService : IBrowserService
{
    string PreviewJavaScript(string source);
}