X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FBuffer.h;h=f745aa04b8563cc2fb43eff35324156c2f5966dd;hb=1a74f3d1035cfbdb5e21947448e5af2b9ec152f0;hp=72c0d8ca097271162bb5ef0075619fe22dff9870;hpb=9388e76dc08442794f49468cffedf1dbf38d7867;p=lyx.git diff --git a/src/Buffer.h b/src/Buffer.h index 72c0d8ca09..f745aa04b8 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -20,6 +20,8 @@ #include "support/types.h" #include "support/SignalSlot.h" +#include +#include #include #include @@ -128,6 +130,9 @@ public: /// Destructor ~Buffer(); + /// + Buffer * clone() const; + /** High-level interface to buffer functionality. This function parses a command string and executes it. */ @@ -154,10 +159,6 @@ public: */ bool readDocument(Lexer &); - /// - void insertStringAsLines(ParagraphList & plist, - pit_type &, pos_type &, - Font const &, docstring const &, bool); /// DocIterator getParFromID(int id) const; /// do we have a paragraph with this id? @@ -174,10 +175,13 @@ public: /// Write document to stream. Returns \c false if unsuccesful. bool write(std::ostream &) const; + /// save emergency file + /// \return a status message towards the user. + docstring emergencyWrite(); /// Write file. Returns \c false if unsuccesful. bool writeFile(support::FileName const &) const; - /// Loads LyX file \c filename into buffer, * and \return success + /// Loads LyX file \c filename into buffer, * and return success bool loadLyXFile(support::FileName const & s); /// Fill in the ErrorList with the TeXErrors @@ -262,9 +266,16 @@ public: /// void setUnnamed(bool flag = true); - /// + /// Whether or not a filename has been assigned to this buffer bool isUnnamed() const; + /// Whether or not this buffer is internal. + /// + /// An internal buffer does not contain a real document, but some auxiliary text segment. + /// It is not associated with a filename, it is never saved, thus it does not need to be + /// automatically saved, nor it needs to trigger any "do you want to save ?" question. + bool isInternal() const; + /// Mark this buffer as dirty. void markDirty(); @@ -304,8 +315,8 @@ public: /// \return true if \p child is a child of this \c Buffer. bool isChild(Buffer * child) const; - /// return a vector with all children and grandchildren - std::vector getChildren() const; + /// return a vector with all children (and grandchildren) + std::vector getChildren(bool grand_children = true) const; /// Is buffer read-only? bool isReadonly() const; @@ -422,6 +433,10 @@ public: /// Return macro defined before the inclusion of the child MacroData const * getMacro(docstring const & name, Buffer const & child, bool global = true) const; + /// Collect user macro names at loading time + typedef std::set UserMacroSet; + UserMacroSet usermacros; + /// Replace the inset contents for insets which InsetCode is equal /// to the passed \p inset_code. void changeRefsIfUnique(docstring const & from, docstring const & to, @@ -455,7 +470,7 @@ public: /// This function is called when the buffer structure is changed. void structureChanged() const; /// This function is called when some parsing error shows up. - void errors(std::string const & err) const; + void errors(std::string const & err, bool from_master = false) const; /// This function is called when the buffer busy status change. void setBusy(bool on) const; /// This function is called when the buffer readonly status change. @@ -506,24 +521,30 @@ public: void setInsetLabel(docstring const & label, InsetLabel const * il); InsetLabel const * insetLabel(docstring const & label) const; + /// return a list of all used branches (also in children) + void getUsedBranches(std::list &, bool const from_master = false) const; + /// sets the buffer_ member for every inset in this buffer. // FIXME This really shouldn't be needed, but at the moment it's not // clear how to do it just for the individual pieces we need. void setBuffersForInsets() const; - /// - void updateLabels(UpdateScope = UpdateMaster) const; - /// - void updateLabels(ParIterator & parit) const; - - /// Find next word starting from \p from. - /// \p from initial position to search, will then points to the next + /// Updates screen labels and some other information associated with + /// insets and paragraphs. Actually, it's more like a general "recurse + /// through the Buffer" routine, that visits all the insets and paragraphs. + void updateLabels() const { updateLabels(UpdateMaster, false); } + /// \param scope: whether to start with the master document or just + /// do this one. + /// \param output: whether we are preparing for output. + void updateLabels(UpdateScope scope, bool output) const; + /// + void updateLabels(ParIterator & parit, bool output) const; + + /// Spellcheck starting from \p from. + /// \p from initial position, will then points to the next misspelled /// word. - /// \p to will points to the end of the next word. - /// \p word will contain the found word if any. - /// \return true if a new word was found. - bool nextWord(DocIterator & from, DocIterator & to, - docstring & word) const; - + /// \p to will points to the end of the next misspelled word. + /// \p word_lang will contain the found misspelled word. + /// \return progress if a new word was found. int spellCheck(DocIterator & from, DocIterator & to, WordLangTuple & word_lang, docstring_list & suggestions) const; @@ -536,7 +557,8 @@ private: */ void updateMacros(DocIterator & it, DocIterator & scope) const; - + /// + void setLabel(ParIterator & it) const; /// void collectRelatives(BufferSet & bufs) const; @@ -550,11 +572,16 @@ private: ReadStatus readFile(Lexer &, support::FileName const & filename, bool fromString = false); + /** If we have branches that use the file suffix + feature, return the file name with suffix appended. + */ + support::FileName exportFileName() const; + /// Use the Pimpl idiom to hide the internals. class Impl; /// The pointer never changes although *pimpl_'s contents may. Impl * const d; - + /// frontend::GuiBufferDelegate * gui_; /// This function is called when the buffer structure is changed.