Main application class for the plain-text editor backend.
More...
#include <undoAppText.hpp>
|
| bool | initialize () |
| | Initialize the plain-text editor (idempotent)
|
| |
| void | shutdown () |
| | Shutdown the plain-text editor.
|
| |
| void | openFile (const std::string &path) |
| | Open a file and load it into the editor.
|
| |
| void | renameFileTo (const std::string &path) |
| | Record that the file this editor holds has moved on disk.
|
| |
| void | saveFile () |
| | Write the editor's current text back to m_currentFilePath.
|
| |
| void | closeFile () |
| | Clear the editor and forget the current file.
|
| |
| void | renderEditorPanel () |
| | Render the editor inside the unified "Editor" ImGui window.
|
| |
| void | setDocument (const std::string &path, const std::string &text) |
| | Put what is on screen back into an editor, under a new file name.
|
| |
| void | document (std::string &path, std::string &text) const |
| | The editor's text and the file it belongs to.
|
| |
| bool | hasUnsavedChanges () const |
| | Whether the text on screen differs from the file on disk.
|
| |
|
| void | setupEditor () |
| | (Re)create the TextEditor widget with the standard dark palette
|
| |
Main application class for the plain-text editor backend.
This is one of three backends owned by undoApp::Editor::EditorApp. It is not registered as an ImGui panel on its own: the EditorApp routes its single "Editor" panel here when the current file is plain text.
◆ closeFile()
| void undoApp::TextApp::closeFile |
( |
| ) |
|
Clear the editor and forget the current file.
◆ document()
| void undoApp::TextApp::document |
( |
std::string & |
path, |
|
|
std::string & |
text |
|
) |
| const |
The editor's text and the file it belongs to.
◆ getInstance()
| static TextApp & undoApp::TextApp::getInstance |
( |
| ) |
|
|
static |
Get the singleton instance of TextApp.
◆ hasUnsavedChanges()
| bool undoApp::TextApp::hasUnsavedChanges |
( |
| ) |
const |
|
inline |
Whether the text on screen differs from the file on disk.
Sticky rather than read from the editor each time it is asked, because TextEditor::IsTextChanged() is a one-shot flag that the next Render() clears. That is what a tab's unsaved mark is answered from, so an answer that expired before the mark was drawn would be an answer that changes on its own.
◆ initialize()
| bool undoApp::TextApp::initialize |
( |
| ) |
|
Initialize the plain-text editor (idempotent)
◆ openFile()
| void undoApp::TextApp::openFile |
( |
const std::string & |
path | ) |
|
Open a file and load it into the editor.
◆ renameFileTo()
| void undoApp::TextApp::renameFileTo |
( |
const std::string & |
path | ) |
|
Record that the file this editor holds has moved on disk.
Only the path, never the text: the editor is still showing the same file, and without this a save after a rename writes a second copy at the old path.
- Parameters
-
| path | Where the file now is |
◆ renderEditorPanel()
| void undoApp::TextApp::renderEditorPanel |
( |
| ) |
|
Render the editor inside the unified "Editor" ImGui window.
◆ saveFile()
| void undoApp::TextApp::saveFile |
( |
| ) |
|
Write the editor's current text back to m_currentFilePath.
◆ setDocument()
| void undoApp::TextApp::setDocument |
( |
const std::string & |
path, |
|
|
const std::string & |
text |
|
) |
| |
Put what is on screen back into an editor, under a new file name.
The two ends of switching tabs. A backend holds one file, so several open means taking the text out of this one before the next is loaded and putting it back when this one is shown again — otherwise a tab that is still open would come back showing the file that replaced it.
The path is separate from the text because it is where a later save goes, and reading it back off disk would lose anything not written yet.
- Parameters
-
| path | The file the text belongs to |
| text | The text as it is now, unsaved changes included |
◆ setupEditor()
| void undoApp::TextApp::setupEditor |
( |
| ) |
|
|
private |
(Re)create the TextEditor widget with the standard dark palette
◆ shutdown()
| void undoApp::TextApp::shutdown |
( |
| ) |
|
Shutdown the plain-text editor.
◆ m_currentFilePath
| std::string undoApp::TextApp::m_currentFilePath |
|
private |
◆ m_editor
| std::unique_ptr<TextEditor> undoApp::TextApp::m_editor |
|
private |
◆ m_initialized
| bool undoApp::TextApp::m_initialized = false |
|
private |
◆ m_isDirty
| bool undoApp::TextApp::m_isDirty = false |
|
private |
Editor text differs from the file on disk.
◆ m_outputLines
| std::vector<std::string> undoApp::TextApp::m_outputLines |
|
private |
The documentation for this class was generated from the following file: