undoStudio
The IDE of the undoRT ecosystem
Loading...
Searching...
No Matches
undoApp::TextApp Class Reference

Main application class for the plain-text editor backend. More...

#include <undoAppText.hpp>

Collaboration diagram for undoApp::TextApp:
Collaboration graph

Public Member Functions

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.
 

Static Public Member Functions

static TextApp & getInstance ()
 Get the singleton instance of TextApp.
 

Private Member Functions

void setupEditor ()
 (Re)create the TextEditor widget with the standard dark palette
 

Private Attributes

bool m_initialized = false
 
std::string m_currentFilePath
 
std::unique_ptr< TextEditor > m_editor
 
std::vector< std::string > m_outputLines
 
bool m_isDirty = false
 Editor text differs from the file on disk.
 

Detailed Description

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.

Member Function Documentation

◆ 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
pathWhere 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
pathThe file the text belongs to
textThe 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.

Member Data Documentation

◆ 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: