SILICON
Loading...
Searching...
No Matches
documentEditors.hpp
Go to the documentation of this file.
1/*
2 Copyright (c) 2026. Giulio Cocconi
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8 */
9
10#pragma once
11
13#include <ui/lifetime.hpp>
14
15namespace SILICON::ui {
16
18class BinaryEditor;
19class CodeEditor;
20struct ProjectSession;
21
22class CodeDocumentEditor final : public DocumentEditor {
23public:
25 EditorNotifications notifications);
27 [[nodiscard]] CodeEditor* editor() const noexcept { return codeEditor.get(); }
28 void zoom(bool in) override;
29 [[nodiscard]] QWidget* widget() const noexcept override;
30 [[nodiscard]] std::shared_ptr<PreparedEditorDocument>
31 prepare(const SILICON::project::Document&) override;
32 void apply(const PreparedEditorDocument&) override;
33 void flush(const std::string&) override;
34 [[nodiscard]] bool isDirty() const override;
35 void resetDirtyState() noexcept override;
36 void reset() override;
37 void undo() override;
38 void redo() override;
39 [[nodiscard]] bool canUndo() const override;
40 [[nodiscard]] bool canRedo() const override;
41 void copy() override;
42 void cut() override;
43 void paste() override;
44 void deleteSelection() override;
45 [[nodiscard]] EditorEditState editState() const override;
46
47private:
49 std::unique_ptr<CodeEditor> codeEditor;
50 bool dirty = false;
52};
53
55public:
57 EditorNotifications notifications);
59 [[nodiscard]] BinaryEditor* editor() const noexcept { return binaryEditor.get(); }
60 void zoom(bool in) override;
61 [[nodiscard]] QWidget* widget() const noexcept override;
62 [[nodiscard]] std::shared_ptr<PreparedEditorDocument>
63 prepare(const SILICON::project::Document&) override;
64 void apply(const PreparedEditorDocument&) override;
65 void flush(const std::string&) override;
66 [[nodiscard]] bool isDirty() const override;
67 void resetDirtyState() noexcept override;
68 void reset() override;
69 void undo() override;
70 void redo() override;
71 [[nodiscard]] bool canUndo() const override;
72 [[nodiscard]] bool canRedo() const override;
73
74private:
76 std::unique_ptr<BinaryEditor> binaryEditor;
77 bool dirty = false;
79};
80
82public:
84 EditorNotifications notifications);
86 void zoom(bool in) override;
87 [[nodiscard]] ArchitectureWorkspace* workspace() const noexcept
88 {
89 return architectureWorkspace.get();
90 }
91 [[nodiscard]] CodeEditor*
92 activeCodeEditor(SILICON::project::DocumentType type) const noexcept;
93 [[nodiscard]] bool isVisualizerActive() const noexcept;
94 [[nodiscard]] QWidget* widget() const noexcept override;
95 [[nodiscard]] std::shared_ptr<PreparedEditorDocument>
96 prepare(const SILICON::project::Document&) override;
97 void apply(const PreparedEditorDocument&) override;
98 void flush(const std::string&) override;
99 [[nodiscard]] bool isDirty() const override;
100 void resetDirtyState() noexcept override;
101 void reset() override;
102 void undo() override;
103 void redo() override;
104 [[nodiscard]] bool canUndo() const override;
105 [[nodiscard]] bool canRedo() const override;
106 void copy() override;
107 void cut() override;
108 void paste() override;
109 void deleteSelection() override;
110 [[nodiscard]] EditorEditState editState() const override;
111
112private:
115 bool dirty = false;
117};
118
119} // namespace SILICON::ui
ArchitectureWorkspace * workspace() const noexcept
ArchitectureDocumentEditor(ProjectSession &session, QWidget *parent, EditorNotifications notifications)
std::unique_ptr< ArchitectureWorkspace > architectureWorkspace
BinaryEditor * editor() const noexcept
std::unique_ptr< BinaryEditor > binaryEditor
BinaryDocumentEditor(ProjectSession &session, QWidget *parent, EditorNotifications notifications)
void resetDirtyState() noexcept override
std::unique_ptr< CodeEditor > codeEditor
CodeDocumentEditor(ProjectSession &session, QWidget *parent, EditorNotifications notifications)
void flush(const std::string &) override
QWidget * widget() const noexcept override
void zoom(bool in) override
Zooms the document in (true) or out (false) by one step.
EditorEditState editState() const override
Reports which generic editing commands the editor currently accepts.
CodeEditor * editor() const noexcept
std::shared_ptr< PreparedEditorDocument > prepare(const SILICON::project::Document &) override
void apply(const PreparedEditorDocument &) override