]> git.lyx.org Git - lyx.git/blobdiff - src/BufferParams.cpp
Allow semantic colors in branches and use semantic background color by default
[lyx.git] / src / BufferParams.cpp
index f3f59cfc445be1c966d7afcbe2d15803574253ae..93a539833bfe93088061cd218baa31d2e4d1054a 100644 (file)
@@ -991,11 +991,16 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                        if (tok == "\\color") {
                                lex.eatLine();
                                string color = lex.getString();
-                               if (branch_ptr)
+                               if (branch_ptr) {
                                        branch_ptr->setColor(color);
+                                       if (branch_ptr->color() == "none")
+                                               color = lcolor.getX11HexName(Color_background);
+                               }
                                // Update also the Color table:
                                if (color == "none")
                                        color = lcolor.getX11HexName(Color_background);
+                               else if (color.size() != 7 || color[0] != '#')
+                                       color = lcolor.getFromLyXName(color);
                                // FIXME UNICODE
                                lcolor.setColor(to_utf8(branch), color);
                        }
@@ -1387,7 +1392,7 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
                os << "\\branch " << to_utf8(br.branch())
                   << "\n\\selected " << br.isSelected()
                   << "\n\\filename_suffix " << br.hasFileNameSuffix()
-                  << "\n\\color " << lyx::X11hexname(br.color())
+                  << "\n\\color " << br.color()
                   << "\n\\end_branch"
                   << "\n";
        }
@@ -2567,7 +2572,7 @@ LayoutFileIndex const & BufferParams::baseClassID() const
 }
 
 
-void BufferParams::makeDocumentClass(bool const clone)
+void BufferParams::makeDocumentClass(bool clone, bool internal)
 {
        if (!baseClass())
                return;
@@ -2577,7 +2582,7 @@ void BufferParams::makeDocumentClass(bool const clone)
        for (auto const & mod : layout_modules_)
                mods.push_back(mod);
 
-       doc_class_ = getDocumentClass(*baseClass(), mods, cite_engine_, clone);
+       doc_class_ = getDocumentClass(*baseClass(), mods, cite_engine_, clone, internal);
 
        TextClass::ReturnValues success = TextClass::OK;
        if (!forced_local_layout_.empty())