Editor for .yaze project files with syntax highlighting and validation. More...
#include <project_file_editor.h>
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. | |
void | set_active (bool active) |
Set whether the editor window is active. | |
bool * | active () |
Get pointer to active state for ImGui. | |
void | SetToastManager (ToastManager *toast_manager) |
Set toast manager for notifications. | |
void | NewFile () |
Create a new empty project file. | |
Private Member Functions | |
void | ApplySyntaxHighlighting () |
void | ValidateContent () |
void | ShowValidationErrors () |
Private Attributes | |
TextEditor | text_editor_ |
std::string | filepath_ |
bool | active_ = false |
bool | modified_ = false |
bool | show_validation_ = true |
std::vector< std::string > | validation_errors_ |
ToastManager * | toast_manager_ = nullptr |
Editor for .yaze project files with syntax highlighting and validation.
Provides a rich text editing experience for yaze project files with:
Definition at line 25 of file project_file_editor.h.
yaze::editor::ProjectFileEditor::ProjectFileEditor | ( | ) |
Definition at line 17 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 23 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_NOTE_ADD, ICON_MD_SAVE, ICON_MD_SAVE_AS, IsModified(), yaze::editor::kError, yaze::editor::kSuccess, LoadFile(), 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::DrawMenuBar().
absl::Status yaze::editor::ProjectFileEditor::LoadFile | ( | const std::string & | filepath | ) |
Load a project file into the editor.
Definition at line 125 of file project_file_editor.cc.
References filepath(), filepath_, modified_, TextEditor::SetText(), text_editor_, and ValidateContent().
Referenced by Draw().
absl::Status yaze::editor::ProjectFileEditor::SaveFile | ( | ) |
Save the current editor contents to disk.
Definition at line 145 of file project_file_editor.cc.
References filepath_, and SaveFileAs().
Referenced by Draw().
absl::Status yaze::editor::ProjectFileEditor::SaveFileAs | ( | const std::string & | filepath | ) |
Save to a new file path.
Definition at line 153 of file project_file_editor.cc.
References filepath(), filepath_, yaze::core::RecentFilesManager::GetInstance(), TextEditor::GetText(), modified_, and text_editor_.
Referenced by Draw(), and SaveFile().
|
inline |
Get whether the file has unsaved changes.
Definition at line 49 of file project_file_editor.h.
References TextEditor::IsTextChanged(), modified_, and text_editor_.
Referenced by Draw().
|
inline |
Get the current filepath.
Definition at line 54 of file project_file_editor.h.
References filepath_.
Referenced by LoadFile(), and SaveFileAs().
|
inline |
Set whether the editor window is active.
Definition at line 59 of file project_file_editor.h.
References active(), and active_.
|
inline |
Get pointer to active state for ImGui.
Definition at line 64 of file project_file_editor.h.
References active_.
Referenced by set_active().
|
inline |
Set toast manager for notifications.
Definition at line 69 of file project_file_editor.h.
References toast_manager_.
Referenced by yaze::editor::EditorManager::Initialize().
void yaze::editor::ProjectFileEditor::NewFile | ( | ) |
Create a new empty project file.
Definition at line 180 of file project_file_editor.cc.
References filepath_, modified_, TextEditor::SetText(), text_editor_, and validation_errors_.
Referenced by Draw().
|
private |
Definition at line 226 of file project_file_editor.cc.
|
private |
Definition at line 231 of file project_file_editor.cc.
References TextEditor::GetText(), yaze::editor::kSuccess, yaze::editor::ToastManager::Show(), show_validation_, text_editor_, toast_manager_, and validation_errors_.
Referenced by Draw(), and LoadFile().
|
private |
Definition at line 278 of file project_file_editor.cc.
References validation_errors_.
|
private |
Definition at line 83 of file project_file_editor.h.
Referenced by Draw(), IsModified(), LoadFile(), NewFile(), ProjectFileEditor(), SaveFileAs(), and ValidateContent().
|
private |
Definition at line 84 of file project_file_editor.h.
Referenced by Draw(), filepath(), LoadFile(), NewFile(), SaveFile(), and SaveFileAs().
|
private |
Definition at line 85 of file project_file_editor.h.
Referenced by active(), Draw(), and set_active().
|
private |
Definition at line 86 of file project_file_editor.h.
Referenced by IsModified(), LoadFile(), NewFile(), and SaveFileAs().
|
private |
Definition at line 87 of file project_file_editor.h.
Referenced by Draw(), and ValidateContent().
|
private |
Definition at line 88 of file project_file_editor.h.
Referenced by Draw(), NewFile(), ShowValidationErrors(), and ValidateContent().
|
private |
Definition at line 89 of file project_file_editor.h.
Referenced by Draw(), SetToastManager(), and ValidateContent().