#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"
-InsetInfo::InsetInfo(Buffer const & buf, string const & name)
+InsetInfo::InsetInfo(Buffer * buf, string const & name)
: InsetCollapsable(buf), type_(UNKNOWN_INFO), name_()
{
setAutoBreakRows(true);
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);
}
_("Missing \\end_inset at this point."),
from_utf8(token));
}
- setLayout(buffer().params());
updateInfo();
}
}
-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, ' '));
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;
}
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;
}
{
// 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:
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);
}
break;
}
if (type_ == SHORTCUT_INFO)
- setText(bindings.begin()->print(KeySequence::Portable),
- Font(inherit_font), false);
+ setText(bindings.begin()->print(KeySequence::Portable));
else
- setText(theTopLevelKeymap().printBindings(func, KeySequence::Portable),
- Font(inherit_font), false);
+ setText(theTopLevelKeymap().printBindings(func, KeySequence::Portable));
break;
}
case LYXRC_INFO: {
// 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();
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);
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;