package p.studio.workspaces.editor;

import javafx.scene.Node;
import javafx.scene.layout.BorderPane;
import org.fxmisc.richtext.CodeArea;
import org.fxmisc.richtext.LineNumberFactory;
import p.studio.projects.ProjectReference;
import p.studio.utilities.i18n.I18n;
import p.studio.workspaces.Workspace;
import p.studio.workspaces.WorkspaceId;

public final class EditorWorkspace extends Workspace {
    private final BorderPane root = new BorderPane();
    private final EditorToolbar toolbar = new EditorToolbar();
    private final CodeArea codeArea = new CodeArea();

    public EditorWorkspace(final ProjectReference projectReference) {
        super(projectReference);
        codeArea.setParagraphGraphicFactory(LineNumberFactory.get(codeArea));
        codeArea.replaceText("""
        fn frame(): void
        {
            // hello Prometeu
        }
        """);

        root.setTop(toolbar);
        root.setCenter(codeArea);
    }

    @Override public WorkspaceId workspaceId() { return WorkspaceId.EDITOR; }
    @Override public I18n title() { return I18n.WORKSPACE_CODE; }
    @Override public Node rootNode() { return root; }

    @Override
    public void load() {

    }

    @Override
    public void unLoad() {

    }

    public CodeArea codeArea() { return codeArea; }
}
