undoStudio
The IDE of the undoRT ecosystem
Loading...
Searching...
No Matches
undoAppCpp.hpp
Go to the documentation of this file.
1
17#pragma once
18
19#include <string>
20#include <vector>
21#include <memory>
22
23// Include TextEditor
24#include <TextEditor.h>
25
26namespace undoApp {
27
36class CppApp
37{
38public:
41
43 bool initialize();
44
46 void shutdown();
47
49 void openFile(const std::string& path);
50
56 void renameFileTo(const std::string& path);
57
59 void saveFile();
60
62 void closeFile();
63
66
79 void setDocument(const std::string& path, const std::string& text);
80
82 void document(std::string& path, std::string& text) const;
83
91 bool hasUnsavedChanges() const { return m_isDirty; }
92
93private:
96
98 std::string getLanguageLabel(const std::string& path) const;
99
100 bool m_initialized = false;
101 std::string m_currentFilePath;
102 std::unique_ptr<TextEditor> m_editor;
103 std::vector<std::string> m_outputLines;
104 bool m_isDirty = false;
105};
106
107} // namespace undoApp
Main application class for the C/C++ editor backend.
Definition undoAppCpp.hpp:37
void shutdown()
Shutdown the C/C++ editor.
void renameFileTo(const std::string &path)
Record that the file this editor holds has moved on disk.
std::vector< std::string > m_outputLines
Definition undoAppCpp.hpp:103
void saveFile()
Write the editor's current text back to m_currentFilePath.
std::string getLanguageLabel(const std::string &path) const
Get the language label based on file extension.
bool hasUnsavedChanges() const
Whether the text on screen differs from the file on disk.
Definition undoAppCpp.hpp:91
void openFile(const std::string &path)
Open a file and load it into the editor.
void document(std::string &path, std::string &text) const
The editor's text and the file it belongs to.
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 closeFile()
Clear the editor and forget the current file.
std::unique_ptr< TextEditor > m_editor
Definition undoAppCpp.hpp:102
bool m_isDirty
Editor text differs from the file on disk.
Definition undoAppCpp.hpp:104
void renderEditorPanel()
Render the editor inside the unified "Editor" ImGui window.
static CppApp & getInstance()
Get the singleton instance of CppApp.
void setupEditor()
(Re)create the TextEditor widget with C++ language definition
bool initialize()
Initialize the C/C++ editor (idempotent)
std::string m_currentFilePath
Definition undoAppCpp.hpp:101
bool m_initialized
Definition undoAppCpp.hpp:100
Definition undoAppCpp.hpp:26