Editor for .yaze project files with syntax highlighting and validation. More...
#include <project_file_editor.h>

Public Types | |
| using | SaveGuardCallback |
| using | SaveCompleteCallback |
Public Member Functions | |
| ProjectFileEditor () | |
| void | Draw () |
| absl::Status | LoadFile (const std::string &filepath) |
| Load a project file into the editor. | |
| absl::Status | SaveFile () |
| Save the current editor contents to disk. | |
| absl::Status | SaveFileAs (const std::string &filepath) |
| Save to a new file path. | |
| bool | IsModified () const |
| Get whether the file has unsaved changes. | |
| const std::string & | filepath () const |
| Get the current filepath. | |
| bool | IsInitialized () const |
| ProjectFileEditorState | CaptureState () const |
| void | RestoreState (const ProjectFileEditorState &state, project::YazeProject *project) |
| void | ResetForProject (project::YazeProject *project) |
| void | set_active (bool active) |
| Set whether the editor window is active. | |
| bool * | active () |
| Get pointer to active state for ImGui. | |
| bool | is_active () const |
| void | SetToastManager (ToastManager *toast_manager) |
| Set toast manager for notifications. | |
| void | SetSaveGuardCallback (SaveGuardCallback callback) |
| void | SetSaveCompleteCallback (SaveCompleteCallback callback) |
| absl::Status | CanReplaceDocument () const |
| absl::Status | NewFile () |
| Create a new empty project file. | |
| void | SetProject (project::YazeProject *project) |
| Set the project pointer for label import operations. | |
Private Member Functions | |
| absl::Status | ImportLabelsFromZScream () |
| Import labels from a ZScream DefaultNames.txt file. | |
| void | ApplySyntaxHighlighting () |
| void | ValidateContent () |
| void | ShowValidationErrors () |
| std::string | GetDocumentText () const |
Private Attributes | |
| TextEditor | text_editor_ |
| std::string | filepath_ |
| bool | initialized_ = false |
| bool | active_ = false |
| bool | modified_ = false |
| bool | show_validation_ = true |
| std::vector< std::string > | validation_errors_ |
| ToastManager * | toast_manager_ = nullptr |
| project::YazeProject * | project_ = nullptr |
| SaveGuardCallback | save_guard_callback_ |
| SaveCompleteCallback | save_complete_callback_ |
Editor for .yaze project files with syntax highlighting and validation.
Provides a rich text editing experience for yaze project files with:
Definition at line 37 of file project_file_editor.h.
Definition at line 39 of file project_file_editor.h.
Definition at line 41 of file project_file_editor.h.
| yaze::editor::ProjectFileEditor::ProjectFileEditor | ( | ) |
Definition at line 63 of file project_file_editor.cc.
References TextEditor::LanguageDefinition::C(), TextEditor::SetLanguageDefinition(), TextEditor::SetShowWhitespaces(), TextEditor::SetTabSize(), and text_editor_.

| void yaze::editor::ProjectFileEditor::Draw | ( | ) |
Definition at line 69 of file project_file_editor.cc.
References active_, filepath_, ICON_MD_CHECK_CIRCLE, ICON_MD_DESCRIPTION, ICON_MD_ERROR, ICON_MD_FOLDER_OPEN, ICON_MD_LABEL, ICON_MD_NOTE_ADD, ICON_MD_SAVE, ICON_MD_SAVE_AS, ImportLabelsFromZScream(), IsModified(), TextEditor::IsTextChanged(), yaze::editor::kError, yaze::editor::kSuccess, LoadFile(), modified_, NewFile(), TextEditor::Render(), SaveFile(), SaveFileAs(), yaze::editor::ToastManager::Show(), show_validation_, yaze::util::FileDialogWrapper::ShowOpenFileDialog(), yaze::util::FileDialogWrapper::ShowSaveFileDialog(), text_editor_, toast_manager_, ValidateContent(), and validation_errors_.
Referenced by yaze::editor::EditorManager::DrawSecondaryWindows().
| absl::Status yaze::editor::ProjectFileEditor::LoadFile | ( | const std::string & | filepath | ) |
Load a project file into the editor.
Definition at line 241 of file project_file_editor.cc.
References CanReplaceDocument(), filepath(), filepath_, initialized_, modified_, project_, RETURN_IF_ERROR, TextEditor::SetText(), text_editor_, and ValidateContent().
Referenced by Draw(), yaze::editor::EditorManager::RebaseCleanProjectFileDraft(), and yaze::editor::EditorManager::ShowProjectFileEditor().

| absl::Status yaze::editor::ProjectFileEditor::SaveFile | ( | ) |
Save the current editor contents to disk.
Definition at line 276 of file project_file_editor.cc.
References filepath_, and SaveFileAs().
Referenced by Draw(), and yaze::editor::EditorManager::SaveActiveProjectEditingWork().

| absl::Status yaze::editor::ProjectFileEditor::SaveFileAs | ( | const std::string & | filepath | ) |
Save to a new file path.
Definition at line 284 of file project_file_editor.cc.
References filepath(), filepath_, GetDocumentText(), yaze::project::RecentFilesManager::GetInstance(), initialized_, modified_, project_, RETURN_IF_ERROR, save_complete_callback_, save_guard_callback_, and yaze::project::WriteProjectFileAtomically().
Referenced by Draw(), and SaveFile().

|
inline |
Get whether the file has unsaved changes.
Definition at line 66 of file project_file_editor.h.
References modified_.
Referenced by Draw().
|
inline |
Get the current filepath.
Definition at line 71 of file project_file_editor.h.
References filepath_.
Referenced by LoadFile(), yaze::editor::EditorManager::ProjectFileDraftTargetsCurrentProject(), yaze::editor::EditorManager::SaveActiveProjectEditingWork(), and SaveFileAs().
|
inline |
Definition at line 72 of file project_file_editor.h.
References initialized_.
| ProjectFileEditorState yaze::editor::ProjectFileEditor::CaptureState | ( | ) | const |
Definition at line 206 of file project_file_editor.cc.
References yaze::editor::ProjectFileEditorState::active, active_, yaze::editor::ProjectFileEditorState::filepath, filepath_, GetDocumentText(), yaze::editor::ProjectFileEditorState::initialized, initialized_, yaze::editor::ProjectFileEditorState::modified, modified_, yaze::editor::ProjectFileEditorState::show_validation, show_validation_, yaze::editor::ProjectFileEditorState::text, yaze::editor::ProjectFileEditorState::validation_errors, and validation_errors_.
Referenced by yaze::editor::EditorManager::CaptureActiveProjectEditingState(), yaze::editor::EditorManager::RebaseCleanProjectFileDraft(), yaze::editor::EditorManager::SaveActiveProjectEditingWork(), and yaze::editor::EditorManager::ShowProjectFileEditor().

| void yaze::editor::ProjectFileEditor::RestoreState | ( | const ProjectFileEditorState & | state, |
| project::YazeProject * | project ) |
Definition at line 218 of file project_file_editor.cc.
References yaze::editor::ProjectFileEditorState::active, active_, yaze::editor::ProjectFileEditorState::filepath, filepath_, yaze::editor::ProjectFileEditorState::initialized, initialized_, yaze::editor::ProjectFileEditorState::modified, modified_, project_, TextEditor::SetText(), yaze::editor::ProjectFileEditorState::show_validation, show_validation_, yaze::editor::ProjectFileEditorState::text, text_editor_, yaze::editor::ProjectFileEditorState::validation_errors, and validation_errors_.
Referenced by yaze::editor::EditorManager::RestoreProjectEditingStateForSession(), and yaze::editor::EditorManager::ShowProjectFileEditor().

| void yaze::editor::ProjectFileEditor::ResetForProject | ( | project::YazeProject * | project | ) |
Definition at line 230 of file project_file_editor.cc.
References active_, filepath_, initialized_, modified_, project_, TextEditor::SetText(), show_validation_, text_editor_, and validation_errors_.
Referenced by yaze::editor::EditorManager::RestoreProjectContextAfterFailedOpen(), yaze::editor::EditorManager::RestoreProjectEditingStateForSession(), and yaze::editor::EditorManager::ShowProjectFileEditor().

|
inline |
Set whether the editor window is active.
Definition at line 82 of file project_file_editor.h.
References active(), and active_.
Referenced by yaze::editor::EditorManager::RebaseCleanProjectFileDraft(), and yaze::editor::EditorManager::ShowProjectFileEditor().

|
inline |
Get pointer to active state for ImGui.
Definition at line 87 of file project_file_editor.h.
References active_.
Referenced by set_active().
|
inline |
Definition at line 88 of file project_file_editor.h.
References active_.
Referenced by yaze::editor::EditorManager::RebaseCleanProjectFileDraft().
|
inline |
Set toast manager for notifications.
Definition at line 93 of file project_file_editor.h.
References toast_manager_.
Referenced by yaze::editor::EditorManager::InitializeServices().
|
inline |
Definition at line 96 of file project_file_editor.h.
References save_guard_callback_.
Referenced by yaze::editor::EditorManager::InitializeSubsystems().
|
inline |
Definition at line 99 of file project_file_editor.h.
References save_complete_callback_.
Referenced by yaze::editor::EditorManager::InitializeSubsystems().
| absl::Status yaze::editor::ProjectFileEditor::CanReplaceDocument | ( | ) | const |
Definition at line 338 of file project_file_editor.cc.
References initialized_, and modified_.
Referenced by LoadFile(), and NewFile().
| absl::Status yaze::editor::ProjectFileEditor::NewFile | ( | ) |
Create a new empty project file.
Definition at line 346 of file project_file_editor.cc.
References CanReplaceDocument(), and RETURN_IF_ERROR.
Referenced by Draw().

|
inline |
Set the project pointer for label import operations.
Definition at line 114 of file project_file_editor.h.
References project_.
Referenced by yaze::editor::EditorManager::RebaseCleanProjectFileDraft(), and yaze::editor::EditorManager::ShowProjectFileEditor().
|
private |
Import labels from a ZScream DefaultNames.txt file.
Definition at line 438 of file project_file_editor.cc.
Referenced by Draw().
|
private |
Definition at line 361 of file project_file_editor.cc.
|
private |
Definition at line 366 of file project_file_editor.cc.
Referenced by Draw(), and LoadFile().
|
private |
Definition at line 428 of file project_file_editor.cc.
|
private |
Definition at line 418 of file project_file_editor.cc.
Referenced by CaptureState(), and SaveFileAs().
|
private |
Definition at line 127 of file project_file_editor.h.
Referenced by Draw(), LoadFile(), ProjectFileEditor(), ResetForProject(), and RestoreState().
|
private |
Definition at line 128 of file project_file_editor.h.
Referenced by CaptureState(), Draw(), filepath(), LoadFile(), ResetForProject(), RestoreState(), SaveFile(), and SaveFileAs().
|
private |
Definition at line 129 of file project_file_editor.h.
Referenced by CanReplaceDocument(), CaptureState(), IsInitialized(), LoadFile(), ResetForProject(), RestoreState(), and SaveFileAs().
|
private |
Definition at line 130 of file project_file_editor.h.
Referenced by active(), CaptureState(), Draw(), is_active(), ResetForProject(), RestoreState(), and set_active().
|
private |
Definition at line 131 of file project_file_editor.h.
Referenced by CanReplaceDocument(), CaptureState(), Draw(), IsModified(), LoadFile(), ResetForProject(), RestoreState(), and SaveFileAs().
|
private |
Definition at line 132 of file project_file_editor.h.
Referenced by CaptureState(), Draw(), ResetForProject(), and RestoreState().
|
private |
Definition at line 133 of file project_file_editor.h.
Referenced by CaptureState(), Draw(), ResetForProject(), and RestoreState().
|
private |
Definition at line 134 of file project_file_editor.h.
Referenced by Draw(), and SetToastManager().
|
private |
Definition at line 135 of file project_file_editor.h.
Referenced by LoadFile(), ResetForProject(), RestoreState(), SaveFileAs(), and SetProject().
|
private |
Definition at line 136 of file project_file_editor.h.
Referenced by SaveFileAs(), and SetSaveGuardCallback().
|
private |
Definition at line 137 of file project_file_editor.h.
Referenced by SaveFileAs(), and SetSaveCompleteCallback().