]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
Fix setting Interlingua as GUI language
[lyx.git] / src / Buffer.cpp
index 1eaa6ac224b201a172bbe3f063f470252d4c52d7..54da9b24ea394bc0f7dbfa3f5b685bc4d00565a6 100644 (file)
@@ -219,7 +219,13 @@ public:
        mutable TocBackend toc_backend;
 
        /// macro tables
-       typedef pair<DocIterator, MacroData> ScopeMacro;
+       struct ScopeMacro {
+               ScopeMacro() {}
+               ScopeMacro(DocIterator const & s, MacroData const & m)
+                       : scope(s), macro(m) {}
+               DocIterator scope;
+               MacroData macro;
+       };
        typedef map<DocIterator, ScopeMacro> PositionScopeMacroMap;
        typedef map<docstring, PositionScopeMacroMap> NamePositionScopeMacroMap;
        /// map from the macro name to the position map,
@@ -230,7 +236,13 @@ public:
 
        /// positions of child buffers in the buffer
        typedef map<Buffer const * const, DocIterator> BufferPositionMap;
-       typedef pair<DocIterator, Buffer const *> ScopeBuffer;
+       struct ScopeBuffer {
+               ScopeBuffer() {}
+               ScopeBuffer(DocIterator const & s,Buffer const * b)
+                       : scope(s), buffer(b) {}
+               DocIterator scope;
+               Buffer const * buffer;
+       };
        typedef map<DocIterator, ScopeBuffer> PositionScopeBufferMap;
        /// position of children buffers in this buffer
        BufferPositionMap children_positions;
@@ -385,9 +397,10 @@ Buffer::Impl::Impl(Buffer * owner, FileName const & file, bool readonly_,
          file_fully_loaded(false), ignore_parent(false), toc_backend(owner),
          macro_lock(false), timestamp_(0), checksum_(0), wa_(0), gui_(0),
          undo_(*owner), bibinfo_cache_valid_(false), bibfile_cache_valid_(false),
-         cite_labels_valid_(false), preview_loader_(0),
+         cite_labels_valid_(false), inset(0), preview_loader_(0),
          cloned_buffer_(cloned_buffer), clone_list_(0),
-         doing_export(false), parent_buffer(0)
+         doing_export(false), parent_buffer(0),
+         word_count_(0), char_count_(0), blank_count_(0)
 {
        if (!cloned_buffer_) {
                temppath = createBufferTmpDir();
@@ -558,7 +571,7 @@ void Buffer::cloneWithChildren(BufferMap & bufmap, CloneList * clones) const
        for (; it != end; ++it) {
                DocIterator dit = it->first.clone(buffer_clone);
                dit.setBuffer(buffer_clone);
-               Buffer * child = const_cast<Buffer *>(it->second.second);
+               Buffer * child = const_cast<Buffer *>(it->second.buffer);
 
                child->cloneWithChildren(bufmap, clones);
                BufferMap::iterator const bit = bufmap.find(child);
@@ -775,7 +788,7 @@ string Buffer::logName(LogType * type) const
 
        // Also consider the master buffer log file
        FileName masterfname = fname;
-       LogType mtype;
+       LogType mtype = latexlog;
        if (masterBuffer() != this) {
                string const mlogfile = masterBuffer()->logName(&mtype);
                masterfname = FileName(mlogfile);
@@ -1526,7 +1539,7 @@ bool Buffer::write(ostream & ofs) const
        // how to check if close went ok?
        // Following is an attempt... (BE 20001011)
 
-       // good() returns false if any error occured, including some
+       // good() returns false if any error occurred, including some
        //        formatting error.
        // bad()  returns true if something bad happened in the buffer,
        //        which should include file system full errors.
@@ -1635,6 +1648,11 @@ void Buffer::writeLaTeXSource(otexstream & os,
 
        OutputParams runparams = runparams_in;
 
+       // This is necessary for LuaTeX/XeTeX with tex fonts.
+       // See FIXME in BufferParams::encoding()
+       if (runparams.isFullUnicode())
+               runparams.encoding = encodings.fromLyXName("utf8-plain");
+
        // If we are compiling a file standalone, even if this is the
        // child of some other buffer, let's cut the link here, so the
        // file is really independent and no concurring settings from
@@ -1846,7 +1864,7 @@ void Buffer::writeDocBookSource(odocstream & os, string const & fname,
        d->texrow.reset();
 
        DocumentClass const & tclass = params().documentClass();
-       string const top_element = tclass.latexname();
+       string const top_element = tclass.latexname();
 
        bool const output_preamble =
                output == FullSource || output == OnlyPreamble;
@@ -2543,7 +2561,7 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
                bool const activate = (func.action() == LFUN_BRANCH_ACTIVATE
                                       || func.action() == LFUN_BRANCH_MASTER_ACTIVATE);
                if (branch->isSelected() != activate) {
-                       buf->undo().recordUndoFullDocument(CursorData());
+                       buf->undo().recordUndoBufferParams(CursorData());
                        branch->setSelected(activate);
                        dr.setError(false);
                        dr.screenUpdate(Update::Force);
@@ -2573,7 +2591,7 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
                                        msg += ("\n");
                                msg += bformat(_("Branch \"%1$s\" already exists."), branch_name);
                        } else {
-                               undo().recordUndoFullDocument(CursorData());
+                               undo().recordUndoBufferParams(CursorData());
                                branch_list.add(branch_name);
                                branch = branch_list.find(branch_name);
                                string const x11hexname = X11hexname(branch->color());
@@ -3116,12 +3134,12 @@ MacroData const * Buffer::Impl::getBufferMacro(docstring const & name,
                if (it != nameIt->second.end()) {
                        while (true) {
                                // scope ends behind pos?
-                               if (pos < it->second.first) {
+                               if (pos < it->second.scope) {
                                        // Looks good, remember this. If there
                                        // is no external macro behind this,
                                        // we found the right one already.
                                        bestPos = it->first;
-                                       bestData = &it->second.second;
+                                       bestData = &it->second.macro;
                                        break;
                                }
 
@@ -3146,13 +3164,13 @@ MacroData const * Buffer::Impl::getBufferMacro(docstring const & name,
                        break;
 
                // scope ends behind pos?
-               if (pos < it->second.first
+               if (pos < it->second.scope
                        && (cloned_buffer_ ||
-                           theBufferList().isLoaded(it->second.second))) {
+                           theBufferList().isLoaded(it->second.buffer))) {
                        // look for macro in external file
                        macro_lock = true;
                        MacroData const * data
-                               = it->second.second->getMacro(name, false);
+                               = it->second.buffer->getMacro(name, false);
                        macro_lock = false;
                        if (data) {
                                bestPos = it->first;
@@ -3579,7 +3597,7 @@ void Buffer::getSourceCode(odocstream & os, string const & format,
                        setMathFlavor(runparams);
                        xhtmlParagraphs(text(), *this, xs, runparams);
                } else if (runparams.flavor == OutputParams::TEXT) {
-                       bool dummy;
+                       bool dummy = false;
                        // FIXME Handles only one paragraph, unlike the others.
                        // Probably should have some routine with a signature like them.
                        writePlaintextParagraph(*this,