WSF
wizard::TextSource Class Reference

#include <TextSource.hpp>

Inherits UtTextDocument.

Public Types

enum  Flags { cINCLUDED = 1 , cCRITICAL = 2 , cCRITICAL_MASK = cCRITICAL | cINCLUDED }

Public Member Functions

 TextSource (ProjectWorkspace *aProjectManagerPtr, const UtPath &aSourcePath)
virtual ~TextSource ()
void AddedToWorkspace ()
bool Load ()
 Load the file into memory if it has not been loaded.
UtTextDocument * GetSource ()
bool IsDeleted () const
void SetDeleted (bool aIsDeleted)
bool CheckForFileModifications (bool aAlwaysFullyReload)
void HandleInsert (int aPosition, int aLength, const char *aText)
void HandleDelete (int aPosition, int aLength)
TextSourceViewNewView (Project *aProjectPtr)
TextSourceViewGetView (Project *aParentPtr)
const std::vector< TextSourceView * > & GetViews () const
void EditorClosed (Editor *aEditorPtr)
void * GetQtDocument () const
QTextDocument * GetDocumentAsQTextDocument () const
void ProjectParseUpdated ()
bool Save ()
void SaveWithNotifications ()
void SaveAs ()
std::string GetFileName ()
std::string GetSystemPath () const
void Replace (const UtTextRange &aReplaceRange, const std::string &aText)
void Append (const std::string &aText)
const std::vector< TextSourceChange > & GetPendingChanges () const
bool IsModified () const
void SavePointReached ()
bool ReadSource (bool aAlwaysFullyReload=false)
ProjectWorkspaceGetWorkspace () const
ProjectGetProject ()
void WaitForSourceModifications ()
int GetFlags () const
void SetFlags (int aFlags)
bool IsCritical () const
bool IsLoaded () const
void Unload ()
 Unload the file from memory if possible.
void ApplyModifications (UtTextRange &aRange, long long aStartSequenceNumber) const
size_t ApplyModifications (size_t aPos, long long aStartSequenceNumber) const
void ApplyPendingModifications (UtTextRange &aRange, UtTextDocument &aDocument) const
bool HasAppliedChanges (long long aSequenceNumber) const
bool HasPendingChanges () const
FileSignature FileSignatureAtLoad () const
void ReloadViews ()
void FindIncludeLocations ()
void BrowseContainingFolder ()
void CopyPathToClipboard ()

Static Public Member Functions

static long long GetNextSequenceNumber ()
static void SetObsoleteSequenceNumber (long long aNumber)
static void DiffDocuments (const char *aOld, const char *aNew, QVector< TextSourceChange > &aChanges)
 Compute differences between two null-terminated text strings.

Public Attributes

UtCallbackListN< void(TextSource &)> FileModifiedChange
 Executes when file's modification state has changed.

Static Public Attributes

static UtCallbackListN< void(TextSource *, size_t, int)> TextSourceCharDeleted

Friends

class wizard::Project
class wizard::ProjectWorkspace

Detailed Description

TextSource is a file referenced by the project. The file may or may not be loaded into memory. Because of multi-threaded parsing, this class maintains a separate copy of the text when loaded in the text editor. Changes made to the document are queued and only applied when the parser has stopped. While TextSource inherits from UtTextDocument, using mutators from UtTextDocument directly is not advised.

Member Enumeration Documentation

◆ Flags

Enumerator
cINCLUDED 
cCRITICAL 
cCRITICAL_MASK 

Constructor & Destructor Documentation

◆ TextSource()

wizard::TextSource::TextSource ( ProjectWorkspace * aProjectManagerPtr,
const UtPath & aSourcePath )

◆ ~TextSource()

wizard::TextSource::~TextSource ( )
virtual

References Unload(), and wizSignals.

Member Function Documentation

◆ AddedToWorkspace()

void wizard::TextSource::AddedToWorkspace ( )

Referenced by wizard::ProjectWorkspace.

◆ Append()

void wizard::TextSource::Append ( const std::string & aText)

◆ ApplyModifications() [1/2]

size_t wizard::TextSource::ApplyModifications ( size_t aPos,
long long aStartSequenceNumber ) const

◆ ApplyModifications() [2/2]

void wizard::TextSource::ApplyModifications ( UtTextRange & aRange,
long long aStartSequenceNumber ) const

◆ ApplyPendingModifications()

void wizard::TextSource::ApplyPendingModifications ( UtTextRange & aRange,
UtTextDocument & aDocument ) const

◆ BrowseContainingFolder()

void wizard::TextSource::BrowseContainingFolder ( )

◆ CheckForFileModifications()

bool wizard::TextSource::CheckForFileModifications ( bool aAlwaysFullyReload)

◆ CopyPathToClipboard()

void wizard::TextSource::CopyPathToClipboard ( )

◆ DiffDocuments()

void wizard::TextSource::DiffDocuments ( const char * aOld,
const char * aNew,
QVector< TextSourceChange > & aChanges )
static

Compute differences between two null-terminated text strings.

References wizard::TextSourceChange::mCharsRemoved, wizard::TextSourceChange::mPos, and wizard::TextSourceChange::mText.

◆ EditorClosed()

void wizard::TextSource::EditorClosed ( Editor * aEditorPtr)

References GetWorkspace(), and Unload().

◆ FileSignatureAtLoad()

FileSignature wizard::TextSource::FileSignatureAtLoad ( ) const
inline

◆ FindIncludeLocations()

void wizard::TextSource::FindIncludeLocations ( )

◆ GetDocumentAsQTextDocument()

QTextDocument * wizard::TextSource::GetDocumentAsQTextDocument ( ) const
inline

◆ GetFileName()

std::string wizard::TextSource::GetFileName ( )

Referenced by SaveAs().

◆ GetFlags()

int wizard::TextSource::GetFlags ( ) const
inline

◆ GetNextSequenceNumber()

long long wizard::TextSource::GetNextSequenceNumber ( )
inlinestatic

◆ GetPendingChanges()

const std::vector< TextSourceChange > & wizard::TextSource::GetPendingChanges ( ) const
inline

◆ GetProject()

wizard::Project * wizard::TextSource::GetProject ( )

◆ GetQtDocument()

void * wizard::TextSource::GetQtDocument ( ) const
inline

◆ GetSource()

◆ GetSystemPath()

◆ GetView()

◆ GetViews()

const std::vector< TextSourceView * > & wizard::TextSource::GetViews ( ) const
inline

◆ GetWorkspace()

ProjectWorkspace * wizard::TextSource::GetWorkspace ( ) const
inline

◆ HandleDelete()

void wizard::TextSource::HandleDelete ( int aPosition,
int aLength )

Safely deletes text from the document. Text changes must be reconciled by ProjectWorkspace at the appropriate time, therefore, the document will not be updated immediately.

◆ HandleInsert()

void wizard::TextSource::HandleInsert ( int aPosition,
int aLength,
const char * aText )

Safely inserts text into the document. Text changes must be reconciled by ProjectWorkspace at the appropriate time, therefore, the document will not be updated immediately.

◆ HasAppliedChanges()

bool wizard::TextSource::HasAppliedChanges ( long long aSequenceNumber) const

◆ HasPendingChanges()

bool wizard::TextSource::HasPendingChanges ( ) const
inline

◆ IsCritical()

bool wizard::TextSource::IsCritical ( ) const
inline

References cCRITICAL_MASK.

◆ IsDeleted()

bool wizard::TextSource::IsDeleted ( ) const
inline

◆ IsLoaded()

◆ IsModified()

bool wizard::TextSource::IsModified ( ) const
inline

◆ Load()

bool wizard::TextSource::Load ( )

Load the file into memory if it has not been loaded.

References ReadSource().

Referenced by wizard::TextSourceCache::FindSource(), and wizard::TextSourceCache::GetSource().

◆ NewView()

◆ ProjectParseUpdated()

void wizard::TextSource::ProjectParseUpdated ( )

References GetProject(), and wizard::Project.

◆ ReadSource()

bool wizard::TextSource::ReadSource ( bool aAlwaysFullyReload = false)

◆ ReloadViews()

◆ Replace()

void wizard::TextSource::Replace ( const UtTextRange & aReplaceRange,
const std::string & aText )

◆ Save()

◆ SaveAs()

◆ SavePointReached()

void wizard::TextSource::SavePointReached ( )

◆ SaveWithNotifications()

void wizard::TextSource::SaveWithNotifications ( )

References Save(), and SaveWithNotifications().

Referenced by SaveWithNotifications().

◆ SetDeleted()

void wizard::TextSource::SetDeleted ( bool aIsDeleted)

Referenced by ReadSource().

◆ SetFlags()

void wizard::TextSource::SetFlags ( int aFlags)
inline

◆ SetObsoleteSequenceNumber()

void wizard::TextSource::SetObsoleteSequenceNumber ( long long aNumber)
inlinestatic

◆ Unload()

void wizard::TextSource::Unload ( )

Unload the file from memory if possible.

References cCRITICAL_MASK.

Referenced by EditorClosed(), ReadSource(), and ~TextSource().

◆ WaitForSourceModifications()

void wizard::TextSource::WaitForSourceModifications ( )

Referenced by SaveAs().

◆ wizard::Project

friend class wizard::Project
friend

◆ wizard::ProjectWorkspace

Member Data Documentation

◆ FileModifiedChange

UtCallbackListN<void(TextSource&)> wizard::TextSource::FileModifiedChange

Executes when file's modification state has changed.

◆ TextSourceCharDeleted

UtCallbackListN< void(wizard::TextSource *, size_t, int)> wizard::TextSource::TextSourceCharDeleted
static

Callback invoked when the given TextSource has characters removed

Template Parameters
void(TextSource*,size_t,int)is the function signature. The first parameter is the given text source that changed. The second parameter is the position where the text changed. The third parameter is the amount of characters removed from the text.

The documentation for this class was generated from the following files:
Copyrights Multiple, All Rights Reserved