![]() |
undoStudio
The IDE of the undoRT ecosystem
|
Main application class for the Workspace and file routing. More...
#include <undoAppEditor.hpp>

Public Member Functions | |
| void | renderFileTabs () |
| Draw the bar of open files above whichever editor is showing. | |
| bool | initialize () |
| Initialize the editor plugin (called by PluginManager) | |
| void | shutdown () |
| Shutdown the editor plugin and release resources. | |
| void | registerPanels () |
| Register the unified "Editor" panel and "Workspace" panel with ImGuiManager. | |
| FileType | getCurrentFileType () const |
| Get the type of the currently open file. | |
| std::string | getCurrentFilePath () const |
| Get the path of the currently open file (empty when none) | |
| void | openFile (const std::string &path, bool pin=true) |
| Open a file using the appropriate backend for its extension. | |
| void | closeFile () |
| Close the currently open file. | |
| void | renderEditorPanel () |
| Render the unified "Editor" panel by dispatching to the active backend. | |
| void | renderWorkspacePanel () |
| Render the Workspace panel (file tree and workspace management) | |
| void | loadWorkspace (const std::string &path) |
| Load a workspace from the given path. | |
| void | createProject (const std::string &parentDir, const std::string &name) |
| Create a new undoProject. | |
| void | openProject (const std::string &projectDir) |
| Open an existing undoProject from projectDir. | |
| void | closeProject () |
| Close the current undoProject. | |
| bool | isProjectOpen () const |
| True if an undoProject is currently open. | |
Static Public Member Functions | |
| static EditorApp & | getInstance () |
| Get the singleton instance of EditorApp. | |
Private Member Functions | |
| void | buildFileTree (FileNode &node, const std::string &root) |
| Build a hierarchical file tree from a directory path. | |
| void | renderFileTree (FileNode &node) |
| Recursively render the file tree. | |
| void | createNewFile (const std::string &parentPath, const std::string &name) |
| Create a new file with ST template (POU) | |
| void | createNewFolder (const std::string &parentPath, const std::string &name) |
| Create a new folder in the workspace. | |
| void | deleteFile (const std::string &path) |
| Delete a file or folder (shows confirmation popup) | |
| void | renameFile (const std::string &oldPath, const std::string &newName) |
| Rename a file or folder. | |
| void | moveFile (const std::string &sourcePath, const std::string &destDir) |
| Move a file to a destination directory. | |
| void | openWorkspaceDialog () |
| Open a native folder selection dialog. | |
| void | createNewGenericFile (const std::string &parentPath, const std::string &name) |
| Create generic file. | |
| void | refreshFileTree () |
| Refresh the file tree. | |
| void | openFileAsText (const std::string &path) |
| Open a JSON file as plain text (bypass JSON viewer) | |
| void | openFileAsTree (const std::string &path) |
| Open a JSON file in the tree viewer, whatever it opens as by default. | |
| std::string | toLower (std::string s) |
| Get the file extension in lowercase. | |
| void | expandToPath (FileNode &node, const std::string &targetPath) |
| void | stashActiveDocument (bool keep) |
| Take the file on screen out of its backend, into its own stash. | |
| void | refreshDirtyState () |
| Ask the backend on screen whether the file has unsaved changes. | |
| void | saveActiveDocument () |
| Write the file on screen back to disk, whichever kind it is. | |
| void | loadActiveDocument (const std::string &path) |
| Put a file into the editor its backend owns. | |
| void | switchToTab (const std::string &path) |
| Bring a tab to the front, restoring what it held. | |
| void | closeTab (const std::string &path) |
| Close a tab, moving to the one beside it if it was the active one. | |
| size_t | documentIndex (const std::string &path) const |
| Where a file sits in the open list. | |
| void | openDocument (const std::string &path, DocKind kind, bool pin) |
| Open a file with a chosen backend, through the tab bar and the model. | |
| void | followPathChange (const std::string &oldPath, const std::string &newPath) |
| Follow a file that was renamed or moved on disk. | |
| void | closeDocumentsUnder (const std::string &path) |
| Close every tab under a path, including the files inside a folder. | |
| void | dropStashes (const std::string &path) |
| Forget everything stashed for a path. | |
| std::string | neighbourAfterClose (const std::string &path) const |
| The tab to show after closing one. | |
Static Private Member Functions | |
| static DocKind | docKindFor (FileType type) |
| Which backend a document kind belongs to. | |
| static FileType | fileTypeFor (DocKind kind) |
Static Private Attributes | |
| static constexpr size_t | kNoIndex = static_cast<size_t>(-1) |
| Says "not found", for a lookup that may genuinely have no answer. | |
Main application class for the Workspace and file routing.
|
private |
Build a hierarchical file tree from a directory path.
|
private |
Close every tab under a path, including the files inside a folder.
| path | File or folder that is gone |
| void undoApp::Editor::EditorApp::closeFile | ( | ) |
Close the currently open file.
| void undoApp::Editor::EditorApp::closeProject | ( | ) |
Close the current undoProject.
|
private |
Close a tab, moving to the one beside it if it was the active one.
|
private |
Create a new file with ST template (POU)
|
private |
Create a new folder in the workspace.
|
private |
Create generic file.
| void undoApp::Editor::EditorApp::createProject | ( | const std::string & | parentDir, |
| const std::string & | name | ||
| ) |
Create a new undoProject.
|
private |
Delete a file or folder (shows confirmation popup)
Which backend a document kind belongs to.
|
private |
Where a file sits in the open list.
|
private |
Forget everything stashed for a path.
| path | Path to drop |
|
private |
|
private |
Follow a file that was renamed or moved on disk.
The one place that knows what a path change means: the tab and its stash are keyed by path, the editor on screen saves to the path it was given, and the recent files list points at a file that is no longer there. Anything holding a path and left behind is now pointing at two different files.
| oldPath | Path the file was known by |
| newPath | Path it now has |
|
inline |
Get the path of the currently open file (empty when none)
|
inline |
Get the type of the currently open file.
|
static |
Get the singleton instance of EditorApp.
| bool undoApp::Editor::EditorApp::initialize | ( | ) |
Initialize the editor plugin (called by PluginManager)
| bool undoApp::Editor::EditorApp::isProjectOpen | ( | ) | const |
True if an undoProject is currently open.
|
private |
Put a file into the editor its backend owns.
| path | The file to show |
| void undoApp::Editor::EditorApp::loadWorkspace | ( | const std::string & | path | ) |
Load a workspace from the given path.
|
private |
Move a file to a destination directory.
Tracks the open documents under the new path for the same reason a rename does: the tab, the stash and the editor all hold the path, not the file.
| sourcePath | Path of the file to move |
| destDir | Directory to move it into |
|
private |
The tab to show after closing one.
|
private |
Open a file with a chosen backend, through the tab bar and the model.
| path | File to open |
| kind | Which backend holds it |
| pin | Whether the file keeps its tab |
| void undoApp::Editor::EditorApp::openFile | ( | const std::string & | path, |
| bool | pin = true |
||
| ) |
Open a file using the appropriate backend for its extension.
Every route into the editor ends up here, which is what makes this the one place that knows a file was looked at, and the one place that decides whether the open was browsing or deliberate.
Also records the file in the recent files list, so that a file opened here and then closed is still reachable afterwards.
| path | File to open |
| pin | Whether the file keeps its tab. True by default, because a file somebody asked to see should still be there when they ask for another one: with a single click into the tree opening a preview, the file being read vanished the moment the next click landed, and what to do about that — double click it, remember to click twice — is not something to leave to a user who is trying to read code. False is for a caller that is deliberately browsing and wants the file to give way to the next one; the tab bar marks such a tab with a tilde. |
|
private |
|
private |
Open a JSON file in the tree viewer, whatever it opens as by default.
The other half of openFileAsText, and it exists for the same reason. A project's own configuration opens as text because it is the file the user is told to edit by hand, and a tree has nothing to type into; but exports.json is nested and reads badly flat, and the tree is how you look at it. One file, one tab, whichever of the two the file was opened with.
| void undoApp::Editor::EditorApp::openProject | ( | const std::string & | projectDir | ) |
Open an existing undoProject from projectDir.
|
private |
Open a native folder selection dialog.
|
private |
Ask the backend on screen whether the file has unsaved changes.
The tab bar's mark is drawn from this, once a frame. Answering it here rather than where the text changes is what makes the mark mean one thing: it appears when there is something to lose and goes away when the file has been written.
|
private |
Refresh the file tree.
| void undoApp::Editor::EditorApp::registerPanels | ( | ) |
Register the unified "Editor" panel and "Workspace" panel with ImGuiManager.
|
private |
Rename a file or folder.
A rename of a file that is open moves its tab, its stash and the editor on screen with it. The tab is keyed by path, and a save writes to the path the editor was told about, so a rename that left those behind would show a name that is not there and save a second copy where the file used to be.
| oldPath | Path of the file or folder to rename |
| newName | The new name, in the same folder |
| void undoApp::Editor::EditorApp::renderEditorPanel | ( | ) |
Render the unified "Editor" panel by dispatching to the active backend.
| void undoApp::Editor::EditorApp::renderFileTabs | ( | ) |
Draw the bar of open files above whichever editor is showing.
|
private |
Recursively render the file tree.
| void undoApp::Editor::EditorApp::renderWorkspacePanel | ( | ) |
Render the Workspace panel (file tree and workspace management)
|
private |
Write the file on screen back to disk, whichever kind it is.
The route the save key takes, and the only one that covers every kind: the ST editor draws its own panel and its own save button, so a shortcut handled where the text backends are dispatched from never reached an .st file.
| void undoApp::Editor::EditorApp::shutdown | ( | ) |
Shutdown the editor plugin and release resources.
|
private |
Take the file on screen out of its backend, into its own stash.
| keep | Whether it is a tab rather than a preview about to be reused, in which case it is pinned. Not a statement about unsaved changes: that is what the editors are asked about, in refreshDirtyState(). |
|
private |
Bring a tab to the front, restoring what it held.
|
private |
Get the file extension in lowercase.
|
staticconstexprprivate |
Says "not found", for a lookup that may genuinely have no answer.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
The files that are open, and which is only a preview. See the header of undoAppOpenDocuments.hpp for why there is one preview slot rather than a tab per file opened.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
What each open file's editor holds while another file is in its place.
Keyed by path, not by position in m_open. A preview being dropped shortens that list, so anything indexed beside it slides against the wrong file; a path cannot. A tab that is still open has to come back showing its own text — the unsaved half of every change exists nowhere else — and this is where that text waits.
|
private |
|
private |
|
private |