]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetInfo.cpp
Pure HTML output for math macros.
[lyx.git] / src / insets / InsetInfo.cpp
index c87df0acd1f8025e4f678c65c978898a55c6be51..f521d3b46d8cb092dad18639105234027812c9f8 100644 (file)
@@ -23,8 +23,8 @@
 #include "LayoutFile.h"
 #include "LyXAction.h"
 #include "LyXRC.h"
+#include "LyXVC.h"
 #include "Lexer.h"
-#include "MetricsInfo.h"
 #include "ParagraphParameters.h"
 
 #include "frontends/Application.h"
@@ -82,7 +82,7 @@ NameTranslator const & nameTranslator()
 
 
        
-InsetInfo::InsetInfo(Buffer const & buf, string const & name) 
+InsetInfo::InsetInfo(Buffer * buf, string const & name) 
        : InsetCollapsable(buf), type_(UNKNOWN_INFO), name_()
 {
        setAutoBreakRows(true);
@@ -93,8 +93,8 @@ InsetInfo::InsetInfo(Buffer const & buf, string const & name)
 
 Inset * InsetInfo::editXY(Cursor & cur, int x, int y)
 {
-       cur.push(*this);
-       return InsetCollapsable::editXY(cur, x, y);
+       // do not allow the cursor to be set in this Inset
+       return Inset::editXY(cur, x, y);
 }
 
 
@@ -112,10 +112,8 @@ docstring InsetInfo::name() const
 
 docstring InsetInfo::toolTip(BufferView const &, int, int) const
 {
-       odocstringstream os;
-       os << _("Information regarding ")
-          << _(infoType()) << " " << from_utf8(name_);
-       return os.str();
+       return bformat(_("Information regarding %1$s '%2$s'"),
+                       _(infoType()), from_utf8(name_));
 }
 
 
@@ -141,7 +139,6 @@ void InsetInfo::read(Lexer & lex)
                        _("Missing \\end_inset at this point."),
                        from_utf8(token));
        }
-       setLayout(buffer().params());
        updateInfo();
 }
 
@@ -153,7 +150,7 @@ void InsetInfo::write(ostream & os) const
 }
 
 
-bool InsetInfo::validate(docstring const & arg) const
+bool InsetInfo::validateModifyArgument(docstring const & arg) const
 {
        string type;
        string const name = trim(split(to_utf8(arg), type, ' '));
@@ -176,7 +173,9 @@ bool InsetInfo::validate(docstring const & arg) const
        case TEXTCLASS_INFO:
                return true;
        case BUFFER_INFO:
-               return name == "name" || name == "path" || name == "class";
+               return name == "name" || name == "path" || name == "class" ||
+                      name == "vcs-revision" || name == "vcs-tree-revision" ||
+                      name == "vcs-author" || name == "vcs-date" || name == "vcs-time";
        }
        return false;
 }
@@ -193,23 +192,23 @@ bool InsetInfo::getStatus(Cursor & cur, FuncRequest const & cmd,
                FuncStatus & flag) const
 {
        switch (cmd.action) {
-       case LFUN_MOUSE_PRESS:
-       case LFUN_MOUSE_RELEASE:
-       case LFUN_MOUSE_MOTION:
-       case LFUN_MOUSE_DOUBLE:
-       case LFUN_MOUSE_TRIPLE:
-       case LFUN_COPY:
        case LFUN_INSET_SETTINGS:
                return InsetCollapsable::getStatus(cur, cmd, flag);
-
-       case LFUN_INSET_MODIFY:
+               
+       case LFUN_INSET_DIALOG_UPDATE:
                flag.setEnabled(true);
-               break;
-
+               return true;
+               
+       case LFUN_INSET_MODIFY:
+               if (validateModifyArgument(cmd.argument())) {
+                       flag.setEnabled(true);
+                       return true;
+               }
+               //fall back
+               
        default:
                return false;
        }
-       return true;
 }
 
 
@@ -217,19 +216,12 @@ void InsetInfo::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
        // allow selection, copy but not cut, delete etc
        switch (cmd.action) {
-       case LFUN_MOUSE_PRESS:
-       case LFUN_MOUSE_RELEASE:
-       case LFUN_MOUSE_MOTION:
-       case LFUN_MOUSE_DOUBLE:
-       case LFUN_MOUSE_TRIPLE:
-       case LFUN_COPY:
        case LFUN_INSET_SETTINGS:
                InsetCollapsable::doDispatch(cur, cmd);
                break;
 
        case LFUN_INSET_MODIFY:
                setInfo(to_utf8(cmd.argument()));
-               cur.pos() = 0;
                break;
 
        default:
@@ -246,20 +238,20 @@ void InsetInfo::setInfo(string const & name)
        string type;
        name_ = trim(split(name, type, ' '));
        type_ = nameTranslator().find(type);
-       setLayout(buffer().params());
        updateInfo();
 }
 
 
 void InsetInfo::error(string const & err)
 {
-       setText(bformat(_(err), from_utf8(name_)), Font(inherit_font), false);
+       setText(bformat(_(err), from_utf8(name_)), 
+               Font(inherit_font, buffer().params().language), false);
 }
 
 
 void InsetInfo::setText(docstring const & str)
 {
-       setText(str, Font(inherit_font), false);
+       setText(str, Font(inherit_font, buffer().params().language), false);
 }
 
 
@@ -285,11 +277,9 @@ void InsetInfo::updateInfo()
                        break;
                }
                if (type_ == SHORTCUT_INFO)
-                       setText(bindings.rbegin()->print(KeySequence::Portable),
-                               Font(getLayout().font()), false);
+                       setText(bindings.begin()->print(KeySequence::Portable));
                else
-                       setText(theTopLevelKeymap().printBindings(func), 
-                               Font(getLayout().font()), false);
+                       setText(theTopLevelKeymap().printBindings(func, KeySequence::Portable));
                break;
        }
        case LYXRC_INFO: {
@@ -328,7 +318,7 @@ void InsetInfo::updateInfo()
                // if found, return its path.
                clear();
                Paragraph & par = paragraphs().front();
-               Font const f = Font(getLayout().font());
+               Font const f(inherit_font, buffer().params().language);
                //Font fu = f;
                //fu.fontInfo().setUnderbar(FONT_ON);
                docstring_list::const_iterator beg = names.begin();
@@ -360,7 +350,7 @@ void InsetInfo::updateInfo()
                FileName file(to_utf8(icon_name));
                if (!file.exists())
                        break;
-               InsetGraphics * inset = new InsetGraphics(buffer());
+               InsetGraphics * inset = new InsetGraphics(buffer_);
                InsetGraphicsParams igp;
                igp.filename = file;
                inset->setParams(igp);
@@ -376,6 +366,21 @@ void InsetInfo::updateInfo()
                        setText(from_utf8(buffer().filePath()));
                else if (name_ == "class")
                        setText(from_utf8(bp.documentClass().name()));
+               else if (name_ == "vcs-revision" && buffer().lyxvc().inUse() &&
+                        !buffer().lyxvc().revisionInfo(LyXVC::File).empty())
+                       setText(from_utf8(buffer().lyxvc().revisionInfo(LyXVC::File)));
+               else if (name_ == "vcs-tree-revision" && buffer().lyxvc().inUse() &&
+                        !buffer().lyxvc().revisionInfo(LyXVC::Tree).empty())
+                       setText(from_utf8(buffer().lyxvc().revisionInfo(LyXVC::Tree)));
+               else if (name_ == "vcs-author" && buffer().lyxvc().inUse() &&
+                        !buffer().lyxvc().revisionInfo(LyXVC::Author).empty())
+                       setText(from_utf8(buffer().lyxvc().revisionInfo(LyXVC::Author)));
+               else if (name_ == "vcs-time" && buffer().lyxvc().inUse() &&
+                        !buffer().lyxvc().revisionInfo(LyXVC::Time).empty())
+                       setText(from_utf8(buffer().lyxvc().revisionInfo(LyXVC::Time)));
+               else if (name_ == "vcs-date" && buffer().lyxvc().inUse() &&
+                        !buffer().lyxvc().revisionInfo(LyXVC::Date).empty())
+                       setText(from_utf8(buffer().lyxvc().revisionInfo(LyXVC::Date)));
                else
                        setText(_("Unknown buffer info"));
                break;