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

The set of open files, at most one of them a preview. More...

#include <undoAppOpenDocuments.hpp>

Collaboration diagram for undoApp::OpenDocuments:
Collaboration graph

Classes

struct  CloseOutcome
 Close a document. More...
 
struct  DirtySummary
 Close every document that has changes. More...
 

Public Member Functions

OpenOutcome open (const std::string &path, DocKind kind)
 Open a file, taking the preview slot.
 
bool pin (const std::string &path)
 Make a document permanent.
 
void setDirty (const std::string &path, bool dirty)
 Record whether a document has changes not written to disk.
 
void setClean (const std::string &path)
 Record that a document's changes have been written.
 
CloseOutcome close (const std::string &path)
 
bool rename (const std::string &oldPath, const std::string &newPath)
 Follow a file that was renamed or moved on disk.
 
bool activate (const std::string &path)
 Bring a document to the front without reopening it.
 
DirtySummary closeAll ()
 
const std::vector< OpenDocument > & documents () const
 
const std::string & active () const
 
size_t size () const
 
bool isOpen (const std::string &path) const
 Whether a document is open.
 
size_t pinnedCount () const
 How many documents are pinned.
 
const std::string * cycle (int direction)
 Move to the next or previous document, wrapping round.
 

Private Attributes

std::vector< OpenDocument > m_documents
 
std::string m_active
 

Detailed Description

The set of open files, at most one of them a preview.

Member Function Documentation

◆ activate()

bool undoApp::OpenDocuments::activate ( const std::string &  path)
inline

Bring a document to the front without reopening it.

◆ active()

const std::string & undoApp::OpenDocuments::active ( ) const
inline

◆ close()

CloseOutcome undoApp::OpenDocuments::close ( const std::string &  path)
inline

◆ closeAll()

DirtySummary undoApp::OpenDocuments::closeAll ( )
inline

◆ cycle()

const std::string * undoApp::OpenDocuments::cycle ( int  direction)
inline

Move to the next or previous document, wrapping round.

Moves the active tab rather than only reporting where it would go: this is what Ctrl+Tab does, and a version that answered the question without acting on it would leave the shortcut doing nothing.

Parameters
direction1 for the next, -1 for the previous
Returns
The document now active, or nullptr when there are none

◆ documents()

const std::vector< OpenDocument > & undoApp::OpenDocuments::documents ( ) const
inline

◆ isOpen()

bool undoApp::OpenDocuments::isOpen ( const std::string &  path) const
inline

Whether a document is open.

◆ open()

OpenOutcome undoApp::OpenDocuments::open ( const std::string &  path,
DocKind  kind 
)
inline

Open a file, taking the preview slot.

A file that is already open is focused rather than opened twice: the tabs are where the user looks to see what is open, and a file appearing in two of them would make that a worse answer than no tabs at all.

◆ pin()

bool undoApp::OpenDocuments::pin ( const std::string &  path)
inline

Make a document permanent.

Returns
Whether it was open

◆ pinnedCount()

size_t undoApp::OpenDocuments::pinnedCount ( ) const
inline

How many documents are pinned.

◆ rename()

bool undoApp::OpenDocuments::rename ( const std::string &  oldPath,
const std::string &  newPath 
)
inline

Follow a file that was renamed or moved on disk.

The path is the identity of a document here: it is the tab's ImGui id and the key every stash is held under, so it has to move with the file, or the tab bar shows a name that is not there and a save writes a second copy where the file used to be. The document keeps its place in the list, its mark and whether it is pinned: it is the same file, and this is not a save.

Parameters
oldPathThe path the document was opened under
newPathThe path it now has
Returns
Whether a document was open under oldPath

◆ setClean()

void undoApp::OpenDocuments::setClean ( const std::string &  path)
inline

Record that a document's changes have been written.

◆ setDirty()

void undoApp::OpenDocuments::setDirty ( const std::string &  path,
bool  dirty 
)
inline

Record whether a document has changes not written to disk.

A preview that has just been edited is pinned: it now holds work, and the next click in the tree must not be able to discard it.

◆ size()

size_t undoApp::OpenDocuments::size ( ) const
inline

Member Data Documentation

◆ m_active

std::string undoApp::OpenDocuments::m_active
private

◆ m_documents

std::vector<OpenDocument> undoApp::OpenDocuments::m_documents
private

The documentation for this class was generated from the following file: