]> git.lyx.org Git - lyx.git/blob - src/insets/InsetInfo.cpp
Make inset info icons tight again!
[lyx.git] / src / insets / InsetInfo.cpp
1 /**
2  * \file InsetInfo.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Bo Peng
7  * \author Jürgen Spitzmüller
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11 #include <config.h>
12
13 #include "InsetInfo.h"
14 #include "LyX.h"
15 #include "Buffer.h"
16 #include "BufferParams.h"
17 #include "BufferView.h"
18 #include "Changes.h"
19 #include "Cursor.h"
20 #include "CutAndPaste.h"
21 #include "Font.h"
22 #include "FuncRequest.h"
23 #include "FuncStatus.h"
24 #include "InsetGraphics.h"
25 #include "InsetSpecialChar.h"
26 #include "KeyMap.h"
27 #include "LaTeXFeatures.h"
28 #include "Language.h"
29 #include "LayoutFile.h"
30 #include "LyXAction.h"
31 #include "LyXRC.h"
32 #include "LyXVC.h"
33 #include "Lexer.h"
34 #include "Paragraph.h"
35 #include "ParIterator.h"
36 #include "ParagraphParameters.h"
37 #include "version.h"
38
39 #include "frontends/Application.h"
40
41 #include "support/Changer.h"
42 #include "support/convert.h"
43 #include "support/debug.h"
44 #include "support/docstream.h"
45 #include "support/docstring_list.h"
46 #include "support/ExceptionMessage.h"
47 #include "support/FileName.h"
48 #include "support/filetools.h"
49 #include "support/gettext.h"
50 #include "support/Length.h"
51 #include "support/Messages.h"
52 #include "support/lstrings.h"
53 #include "support/qstring_helpers.h"
54 #include "support/Translator.h"
55
56 #include <sstream>
57
58 #include <QtGui/QImage>
59 #include <QDate>
60 #include <QLocale>
61
62 using namespace std;
63 using namespace lyx::support;
64
65 namespace lyx {
66
67 namespace {
68
69 typedef Translator<InsetInfoParams::info_type, string> NameTranslator;
70
71 NameTranslator const initTranslator()
72 {
73         NameTranslator translator(InsetInfoParams::UNKNOWN_INFO, "unknown");
74
75         translator.addPair(InsetInfoParams::SHORTCUTS_INFO, "shortcuts");
76         translator.addPair(InsetInfoParams::SHORTCUT_INFO, "shortcut");
77         translator.addPair(InsetInfoParams::LYXRC_INFO, "lyxrc");
78         translator.addPair(InsetInfoParams::PACKAGE_INFO, "package");
79         translator.addPair(InsetInfoParams::TEXTCLASS_INFO, "textclass");
80         translator.addPair(InsetInfoParams::MENU_INFO, "menu");
81         translator.addPair(InsetInfoParams::L7N_INFO, "l7n");
82         translator.addPair(InsetInfoParams::ICON_INFO, "icon");
83         translator.addPair(InsetInfoParams::BUFFER_INFO, "buffer");
84         translator.addPair(InsetInfoParams::LYX_INFO, "lyxinfo");
85         translator.addPair(InsetInfoParams::VCS_INFO, "vcs");
86         translator.addPair(InsetInfoParams::DATE_INFO, "date");
87         translator.addPair(InsetInfoParams::MODDATE_INFO, "moddate");
88         translator.addPair(InsetInfoParams::FIXDATE_INFO, "fixdate");
89         translator.addPair(InsetInfoParams::TIME_INFO, "time");
90         translator.addPair(InsetInfoParams::MODTIME_INFO, "modtime");
91         translator.addPair(InsetInfoParams::FIXTIME_INFO, "fixtime");
92
93         return translator;
94 }
95
96 /// The translator between the information type enum and corresponding string.
97 NameTranslator const & nameTranslator()
98 {
99         static NameTranslator const translator = initTranslator();
100         return translator;
101 }
102
103
104 typedef Translator<InsetInfoParams::info_type, string> DefaultValueTranslator;
105
106 DefaultValueTranslator const initDVTranslator()
107 {
108         DefaultValueTranslator translator(InsetInfoParams::UNKNOWN_INFO, "");
109
110         translator.addPair(InsetInfoParams::SHORTCUTS_INFO, "info-insert");
111         translator.addPair(InsetInfoParams::SHORTCUT_INFO, "info-insert");
112         translator.addPair(InsetInfoParams::LYXRC_INFO, "user_name");
113         translator.addPair(InsetInfoParams::PACKAGE_INFO, "graphics");
114         translator.addPair(InsetInfoParams::TEXTCLASS_INFO, "article");
115         translator.addPair(InsetInfoParams::MENU_INFO, "info-insert");
116         translator.addPair(InsetInfoParams::L7N_INFO, "");
117         translator.addPair(InsetInfoParams::ICON_INFO, "info-insert");
118         translator.addPair(InsetInfoParams::BUFFER_INFO, "name-noext");
119         translator.addPair(InsetInfoParams::LYX_INFO, "version");
120         translator.addPair(InsetInfoParams::VCS_INFO, "revision");
121         translator.addPair(InsetInfoParams::DATE_INFO, "loclong");
122         translator.addPair(InsetInfoParams::MODDATE_INFO, "loclong");
123         translator.addPair(InsetInfoParams::FIXDATE_INFO, "loclong");
124         translator.addPair(InsetInfoParams::TIME_INFO, "long");
125         translator.addPair(InsetInfoParams::MODTIME_INFO, "long");
126         translator.addPair(InsetInfoParams::FIXTIME_INFO, "long");
127
128         return translator;
129 }
130
131 /// The translator between the information type enum and some sensible default value.
132 DefaultValueTranslator const & defaultValueTranslator()
133 {
134         static DefaultValueTranslator const translator = initDVTranslator();
135         return translator;
136 }
137
138 } // namespace
139
140
141 /////////////////////////////////////////////////////////////////////
142 //
143 // InsetInfoParams
144 //
145 ///////////////////////////////////////////////////////////////////////
146
147 InsetInfoParams infoparams;
148
149 namespace{
150 set<string> getTexFileList(string const & filename)
151 {
152         set<string> list;
153         FileName const file = libFileSearch(string(), filename);
154         if (file.empty())
155                 return list;
156
157         // FIXME Unicode.
158         vector<docstring> doclist =
159                 getVectorFromString(file.fileContents("UTF-8"), from_ascii("\n"));
160
161         // Normalise paths like /foo//bar ==> /foo/bar
162         // No "auto const &" because doc is modified later
163         // coverity[auto_causes_copy]
164         for (auto doc : doclist) {
165                 doc = subst(doc, from_ascii("\r"), docstring());
166                 while (contains(doc, from_ascii("//")))
167                         doc = subst(doc, from_ascii("//"), from_ascii("/"));
168                 if (!doc.empty())
169                         list.insert(removeExtension(onlyFileName(to_utf8(doc))));
170         }
171
172         // remove duplicates
173         return list;
174 }
175
176 bool translateString(docstring const & in, docstring & out, string const & lcode)
177 {
178         out = translateIfPossible(in, lcode);
179         return in != out;
180 }
181 } // namespace anon
182
183
184 docstring InsetInfoParams::getDate(string const & iname, QDate const date) const
185 {
186         QLocale loc;
187         if (lang)
188                 loc = QLocale(toqstr(lang->code()));
189         if (iname == "long")
190                 return qstring_to_ucs4(loc.toString(date, QLocale::LongFormat));
191         else if (iname == "short")
192                 return qstring_to_ucs4(loc.toString(date, QLocale::ShortFormat));
193         else if (iname == "ISO")
194                 return qstring_to_ucs4(date.toString(Qt::ISODate));
195         else if (iname == "loclong")
196                 return lang ? qstring_to_ucs4(loc.toString(date, toqstr(lang->dateFormat(0))))
197                             : _("No long date format (language unknown)!");
198         else if (iname == "locmedium")
199                 return lang ? qstring_to_ucs4(loc.toString(date, toqstr(lang->dateFormat(1))))
200                             : _("No medium date format (language unknown)!");
201         else if (iname == "locshort")
202                 return lang ? qstring_to_ucs4(loc.toString(date, toqstr(lang->dateFormat(2))))
203                                 : _("No short date format (language unknown)!");
204         else
205                 return qstring_to_ucs4(loc.toString(date, toqstr(iname)));
206 }
207
208
209 docstring InsetInfoParams::getTime(string const & iname, QTime const time) const
210 {
211         QLocale loc;
212         if (lang)
213                 loc = QLocale(toqstr(lang->code()));
214         if (iname == "long")
215                 return qstring_to_ucs4(loc.toString(time, QLocale::LongFormat));
216         else if (iname == "short")
217                 return qstring_to_ucs4(loc.toString(time, QLocale::ShortFormat));
218         else if (iname == "ISO")
219                 return qstring_to_ucs4(time.toString(Qt::ISODate));
220         else
221                 return qstring_to_ucs4(loc.toString(time, toqstr(iname)));
222 }
223
224
225 vector<pair<string,docstring>> InsetInfoParams::getArguments(Buffer const * buf,
226                                                              string const & itype) const
227 {
228         vector<pair<string,docstring>> result;
229
230         switch (nameTranslator().find(itype)) {
231         case UNKNOWN_INFO:
232                 result.push_back(make_pair("invalid", _("Please select a valid type!")));
233                 break;
234
235         case SHORTCUT_INFO:
236         case SHORTCUTS_INFO:
237         case MENU_INFO:
238         case ICON_INFO: {
239                 result.push_back(make_pair("custom", _("Custom")));
240                 for (auto const & name_code : lyxaction) {
241                         string const lfun = name_code.first;
242                         if (!lfun.empty())
243                                 result.push_back(make_pair(lfun, from_ascii(lfun)));
244                 }
245                 break;
246         }
247
248         case L7N_INFO:
249                 result.push_back(make_pair("custom", _("Custom")));
250                 break;
251
252         case LYXRC_INFO: {
253                 result.push_back(make_pair("custom", _("Custom")));
254                 set<string> rcs = lyxrc.getRCs();
255                 for (auto const & rc : rcs)
256                         result.push_back(make_pair(rc, from_ascii(rc)));
257                 break;
258         }
259
260         case PACKAGE_INFO:
261         case TEXTCLASS_INFO: {
262                 result.push_back(make_pair("custom", _("Custom")));
263                 string const filename = (itype == "package") ? "styFiles.lst"
264                                                             : "clsFiles.lst";
265                 set<string> flist = getTexFileList(filename);
266                 for (auto const & f : flist)
267                         result.push_back(make_pair(f, from_utf8(f)));
268                 break;
269         }
270
271         case BUFFER_INFO:
272                 result.push_back(make_pair("name", _("File name (with extension)")));
273                 result.push_back(make_pair("name-noext", _("File name (without extension)")));
274                 result.push_back(make_pair("path", _("File path")));
275                 result.push_back(make_pair("class", _("Used text class")));
276                 break;
277
278         case VCS_INFO: {
279                 if (!buf->lyxvc().inUse()) {
280                         result.push_back(make_pair("invalid", _("No version control!")));
281                         break;
282                 }
283                 result.push_back(make_pair("revision", _("Revision[[Version Control]]")));
284                 result.push_back(make_pair("revision-abbrev", _("Abbreviated revision[[Version Control]]")));
285                 result.push_back(make_pair("tree-revision", _("Tree revision")));
286                 result.push_back(make_pair("author", _("Author")));
287                 result.push_back(make_pair("date", _("Date")));
288                 result.push_back(make_pair("time", _("Time[[of day]]")));
289                 break;
290         }
291
292         case LYX_INFO:
293                 result.push_back(make_pair("version", _("LyX version")));
294                 result.push_back(make_pair("layoutformat", _("LyX layout format")));
295                 break;
296
297         case FIXDATE_INFO:
298         case DATE_INFO:
299         case MODDATE_INFO: {
300                 string const dt = split(name, '@');
301                 QDate date;
302                 if (itype == "moddate")
303 #if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
304                         date = QDateTime::fromSecsSinceEpoch(buf->fileName().lastModified()).date();
305 #else
306                         date = QDateTime::fromTime_t(buf->fileName().lastModified()).date();
307 #endif
308                 else if (itype == "fixdate" && !dt.empty()) {
309                         QDate const gdate = QDate::fromString(toqstr(dt), Qt::ISODate);
310                         date = (gdate.isValid()) ? gdate : QDate::currentDate();
311                 } else
312                         date = QDate::currentDate();
313                 result.push_back(make_pair("long",getDate("long", date)));
314                 result.push_back(make_pair("short", getDate("short", date)));
315                 result.push_back(make_pair("loclong", getDate("loclong", date)));
316                 result.push_back(make_pair("locmedium", getDate("locmedium", date)));
317                 result.push_back(make_pair("locshort", getDate("locshort", date)));
318                 result.push_back(make_pair("ISO", getDate("ISO", date)));
319                 result.push_back(make_pair("yyyy", getDate("yyyy", date)));
320                 result.push_back(make_pair("MMMM", getDate("MMMM", date)));
321                 result.push_back(make_pair("MMM", getDate("MMM", date)));
322                 result.push_back(make_pair("dddd", getDate("dddd", date)));
323                 result.push_back(make_pair("ddd", getDate("ddd", date)));
324                 result.push_back(make_pair("custom", _("Custom")));
325                 break;
326         }
327         case FIXTIME_INFO:
328         case TIME_INFO:
329         case MODTIME_INFO: {
330                 string const tt = split(name, '@');
331                 QTime time;
332                 if (itype == "modtime")
333 #if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
334                         time = QDateTime::fromSecsSinceEpoch(buf->fileName().lastModified()).time();
335 #else
336                         time = QDateTime::fromTime_t(buf->fileName().lastModified()).time();
337 #endif
338                 else if (itype == "fixtime" && !tt.empty()) {
339                         QTime const gtime = QTime::fromString(toqstr(tt), Qt::ISODate);
340                         time = (gtime.isValid()) ? gtime : QTime::currentTime();
341                 } else
342                         time = QTime::currentTime();
343                 result.push_back(make_pair("long",getTime("long", time)));
344                 result.push_back(make_pair("short", getTime("short", time)));
345                 result.push_back(make_pair("ISO", getTime("ISO", time)));
346                 result.push_back(make_pair("custom", _("Custom")));
347                 break;
348         }
349         }
350
351         return result;
352 }
353
354
355 bool InsetInfoParams::validateArgument(Buffer const * buf, docstring const & arg,
356                                        bool const usedefaults) const
357 {
358         string type;
359         string name = trim(split(to_utf8(arg), type, ' '));
360         if (name.empty() && usedefaults)
361                 name = defaultValueTranslator().find(type);
362
363         switch (nameTranslator().find(type)) {
364         case UNKNOWN_INFO:
365                 return false;
366
367         case SHORTCUT_INFO:
368         case SHORTCUTS_INFO:
369         case MENU_INFO: {
370                 FuncRequest func = lyxaction.lookupFunc(name);
371                 return func.action() != LFUN_UNKNOWN_ACTION;
372         }
373
374         case L7N_INFO:
375                 return !name.empty();
376
377         case ICON_INFO: {
378                 FuncCode const action = lyxaction.lookupFunc(name).action();
379                 if (action == LFUN_UNKNOWN_ACTION) {
380                         string dir = "images";
381                         return !imageLibFileSearch(dir, name, "svgz,png").empty();
382                 }
383                 return true;
384         }
385
386         case LYXRC_INFO: {
387                 set<string> rcs = lyxrc.getRCs();
388                 return rcs.find(name) != rcs.end();
389         }
390
391         case PACKAGE_INFO:
392         case TEXTCLASS_INFO:
393                 return true;
394
395         case BUFFER_INFO:
396                 return (name == "name" || name == "name-noext"
397                         || name == "path" || name == "class");
398
399         case VCS_INFO:
400                 if (name == "revision" || name == "revision-abbrev" || name == "tree-revision"
401                     || name == "author" || name == "date" || name == "time")
402                         return buf->lyxvc().inUse();
403                 return false;
404
405         case LYX_INFO:
406                 return name == "version" || name == "layoutformat";
407
408         case FIXDATE_INFO: {
409                 string date;
410                 string piece;
411                 date = split(name, piece, '@');
412                 if (!date.empty() && !QDate::fromString(toqstr(date), Qt::ISODate).isValid())
413                         return false;
414                 if (!piece.empty())
415                         name = piece;
416         }
417         // fall through
418         case DATE_INFO:
419         case MODDATE_INFO: {
420                 if (name == "long" || name == "short" || name == "ISO")
421                         return true;
422                 else {
423                         QDate date = QDate::currentDate();
424                         return !date.toString(toqstr(name)).isEmpty();
425                 }
426         }
427         case FIXTIME_INFO: {
428                 string time;
429                 string piece;
430                 time = split(name, piece, '@');
431                 if (!time.empty() && !QTime::fromString(toqstr(time), Qt::ISODate).isValid())
432                         return false;
433                 if (!piece.empty())
434                         name = piece;
435         }
436         // fall through
437         case TIME_INFO:
438         case MODTIME_INFO: {
439                 if (name == "long" || name == "short" || name == "ISO")
440                         return true;
441                 else {
442                         QTime time = QTime::currentTime();
443                         return !time.toString(toqstr(name)).isEmpty();
444                 }
445         }
446         }
447
448         return false;
449 }
450
451
452
453
454 string InsetInfoParams::infoType() const
455 {
456         return nameTranslator().find(type);
457 }
458
459
460
461 /////////////////////////////////////////////////////////////////////////
462 //
463 // InsetInfo
464 //
465 /////////////////////////////////////////////////////////////////////////
466
467
468 namespace {
469
470 class InsetGraphicsTight : public InsetGraphics
471 {
472 public:
473         ///
474         explicit InsetGraphicsTight(Buffer * buf) : InsetGraphics(buf) {}
475
476         ///
477         int leftOffset(BufferView const *) const override { return 0; }
478         ///
479         int rightOffset(BufferView const *) const override { return 0; }
480 };
481
482 }
483
484
485 InsetInfo::InsetInfo(Buffer * buf, string const & info)
486         : InsetCollapsible(buf), initialized_(false)
487 {
488         params_.type = InsetInfoParams::UNKNOWN_INFO;
489         params_.force_ltr = false;
490         setInfo(info);
491         status_ = Collapsed;
492 }
493
494
495 Inset * InsetInfo::editXY(Cursor & cur, int x, int y)
496 {
497         // do not allow the cursor to be set in this Inset
498         return Inset::editXY(cur, x, y);
499 }
500
501
502 docstring InsetInfo::layoutName() const
503 {
504         return from_ascii("Info:" + params_.infoType());
505 }
506
507
508 docstring InsetInfo::toolTip(BufferView const &, int, int) const
509 {
510         docstring result;
511         switch (nameTranslator().find(params_.infoType())) {
512         case InsetInfoParams::UNKNOWN_INFO:
513                 result = _("Invalid information inset");
514                 break;
515         case InsetInfoParams::SHORTCUT_INFO:
516                 result = bformat(_("The keybard shortcut for the function '%1$s'"),
517                                 from_utf8(params_.name));
518                 break;
519         case InsetInfoParams::SHORTCUTS_INFO:
520                 result = bformat(_("The keybard shortcuts for the function '%1$s'"),
521                                 from_utf8(params_.name));
522                 break;
523         case InsetInfoParams::MENU_INFO: 
524                 result = bformat(_("The menu location for the function '%1$s'"),
525                                 from_utf8(params_.name));
526                 break;
527         case InsetInfoParams::L7N_INFO: 
528                 result = bformat(_("The localization for the string '%1$s'"),
529                                 from_utf8(params_.name));
530                 break;
531         case InsetInfoParams::ICON_INFO:
532                 result = bformat(_("The toolbar icon for the function '%1$s'"),
533                                 from_utf8(params_.name));
534                 break;
535         case InsetInfoParams::LYXRC_INFO:
536                 result = bformat(_("The preference setting for the preference key '%1$s'"),
537                                 from_utf8(params_.name));
538                 break;
539         case InsetInfoParams::PACKAGE_INFO:
540                 result = bformat(_("Availability of the LaTeX package '%1$s'"),
541                                 from_utf8(params_.name));
542                 break;
543         case InsetInfoParams::TEXTCLASS_INFO:
544                 result = bformat(_("Availability of the LaTeX class '%1$s'"),
545                                 from_utf8(params_.name));
546                 break;
547         case InsetInfoParams::BUFFER_INFO:
548                 if (params_.name == "name")
549                         result = _("The name of this file (incl. extension)");
550                 else if (params_.name == "name-noext")
551                         result = _("The name of this file (without extension)");
552                 else if (params_.name == "path")
553                         result = _("The path where this file is saved");
554                 else if (params_.name == "class")
555                         result = _("The class this document uses");
556                 break;
557         case InsetInfoParams::VCS_INFO:
558                 if (params_.name == "revision")
559                         result = _("Version control revision");
560                 else if (params_.name == "revision-abbrev")
561                         result = _("Version control abbreviated revision");
562                 else if (params_.name == "tree-revision")
563                         result = _("Version control tree revision");
564                 else if (params_.name == "author")
565                          result = _("Version control author");
566                 else if (params_.name == "date")
567                         result = _("Version control date");
568                 else if (params_.name == "time")
569                         result = _("Version control time");
570                 break;
571         case InsetInfoParams::LYX_INFO:
572                 if (params_.name == "version")
573                         result = _("The current LyX version");
574                 else if (params_.name == "layoutformat")
575                         result = _("The current LyX layout format");
576                 break;
577         case InsetInfoParams::DATE_INFO:
578                 result = _("The current date");
579                 break;
580         case InsetInfoParams::MODDATE_INFO:
581                 result = _("The date of last save");
582                 break;
583         case InsetInfoParams::FIXDATE_INFO:
584                 result = _("A static date");
585                 break;
586         case InsetInfoParams::TIME_INFO:
587                 result = _("The current time");
588                 break;
589         case InsetInfoParams::MODTIME_INFO:
590                 result = _("The time of last save");
591                 break;
592         case InsetInfoParams::FIXTIME_INFO:
593                 result = _("A static time");
594                 break;
595         }
596
597         return result;
598 }
599
600
601 void InsetInfo::read(Lexer & lex)
602 {
603         string token;
604         while (lex.isOK()) {
605                 lex.next();
606                 token = lex.getString();
607                 if (token == "type") {
608                         lex.next();
609                         token = lex.getString();
610                         params_.type = nameTranslator().find(token);
611                 } else if (token == "arg") {
612                         lex.next(true);
613                         params_.name = lex.getString();
614                 } else if (token == "\\end_inset")
615                         break;
616         }
617         if (token != "\\end_inset") {
618                 lex.printError("Missing \\end_inset at this point");
619                 throw ExceptionMessage(WarningException,
620                         _("Missing \\end_inset at this point."),
621                         from_utf8(token));
622         }
623 }
624
625
626 void InsetInfo::write(ostream & os) const
627 {
628         os << "Info\ntype  \"" << params_.infoType()
629            << "\"\narg   " << Lexer::quoteString(params_.name);
630 }
631
632
633 bool InsetInfo::showInsetDialog(BufferView * bv) const
634 {
635         bv->showDialog("info");
636         return true;
637 }
638
639
640 bool InsetInfo::getStatus(Cursor & cur, FuncRequest const & cmd,
641                 FuncStatus & flag) const
642 {
643         switch (cmd.action()) {
644         case LFUN_INSET_SETTINGS:
645                 return InsetCollapsible::getStatus(cur, cmd, flag);
646
647         case LFUN_INSET_DIALOG_UPDATE:
648         case LFUN_INSET_COPY_AS:
649         case LFUN_INSET_DISSOLVE:
650                 flag.setEnabled(true);
651                 return true;
652
653         case LFUN_INSET_MODIFY:
654                 if (nameTranslator().find(cmd.getArg(0)) == InsetInfoParams::UNKNOWN_INFO)
655                         return Inset::getStatus(cur, cmd, flag);
656                 if (params_.validateArgument(&buffer(), cmd.argument())) {
657                         flag.setEnabled(true);
658                         string typestr;
659                         string name = trim(split(to_utf8(cmd.argument()), typestr, ' '));
660                         InsetInfoParams::info_type type = nameTranslator().find(typestr);
661                         string origname = params_.name;
662                         if (type == InsetInfoParams::FIXDATE_INFO
663                             || type == InsetInfoParams::FIXTIME_INFO)
664                                 split(params_.name, origname, '@');
665                         flag.setOnOff(type == params_.type && name == origname);
666                         return true;
667                 }
668                 //fall through
669
670         default:
671                 return false;
672         }
673 }
674
675
676 void InsetInfo::doDispatch(Cursor & cur, FuncRequest & cmd)
677 {
678         switch (cmd.action()) {
679         case LFUN_INSET_MODIFY:
680                 if (nameTranslator().find(cmd.getArg(0)) == InsetInfoParams::UNKNOWN_INFO) {
681                         cur.undispatched();
682                         break;
683                 }
684                 cur.recordUndo();
685                 setInfo(to_utf8(cmd.argument()));
686                 cur.forceBufferUpdate();
687                 initialized_ = false;
688                 break;
689
690         case LFUN_INSET_COPY_AS: {
691                 cap::clearSelection();
692                 Cursor copy(cur);
693                 copy.pushBackward(*this);
694                 copy.pit() = 0;
695                 copy.pos() = 0;
696                 copy.resetAnchor();
697                 copy.pit() = copy.lastpit();
698                 copy.pos() = copy.lastpos();
699                 copy.setSelection();
700                 cap::copySelection(copy);
701                 break;
702         }
703
704         default:
705                 InsetCollapsible::doDispatch(cur, cmd);
706                 break;
707         }
708 }
709
710
711 void InsetInfo::setInfo(string const & info)
712 {
713         if (info.empty())
714                 return;
715
716         string saved_date_specifier;
717         // Store old date specifier for potential re-use
718         if (!params_.name.empty())
719                 saved_date_specifier = split(params_.name, '@');
720         // info_type name
721         string type;
722         params_.name = trim(split(info, type, ' '));
723         params_.type = nameTranslator().find(type);
724         if (params_.name.empty())
725                 params_.name = defaultValueTranslator().find(params_.type);
726         if (params_.type == InsetInfoParams::FIXDATE_INFO) {
727                 string const date_specifier = split(params_.name, '@');
728                 // If an explicit new fix date is specified, use that
729                 // Otherwise, use the old one or, if there is none,
730                 // the current date
731                 if (date_specifier.empty()) {
732                         if (saved_date_specifier.empty())
733                                 params_.name += "@" + fromqstr(QDate::currentDate().toString(Qt::ISODate));
734                         else
735                                 params_.name += "@" + saved_date_specifier;
736                 }
737         }
738         else if (params_.type == InsetInfoParams::FIXTIME_INFO) {
739                 string const time_specifier = split(params_.name, '@');
740                 // If an explicit new fix time is specified, use that
741                 // Otherwise, use the old one or, if there is none,
742                 // the current time
743                 if (time_specifier.empty()) {
744                         if (saved_date_specifier.empty())
745                                 params_.name += "@" + fromqstr(QTime::currentTime().toString(Qt::ISODate));
746                         else
747                                 params_.name += "@" + saved_date_specifier;
748                 }
749         }
750 }
751
752
753 void InsetInfo::error(docstring const & err, Language const * lang)
754 {
755         docstring const res = translateIfPossible(err, lang->code());
756         bool const translated = res != err;
757         // If the string is not translated, we use default lang (English)
758         Font const f = translated ? Font(inherit_font, lang) : Font(inherit_font);
759         setText(bformat(res, from_utf8(params_.name)), f, false);
760 }
761
762
763 void InsetInfo::info(docstring const & err, Language const * lang)
764 {
765         docstring const res = translateIfPossible(err, lang->code());
766         bool const translated = res != err;
767         // If the string is not translated, we use default lang (English)
768         Font const f = translated ? Font(inherit_font, lang) : Font(inherit_font);
769         setText(translateIfPossible(err, lang->code()), f, false);
770 }
771
772
773 void InsetInfo::setText(docstring const & str, Language const * lang)
774 {
775         setText(str, Font(inherit_font, lang), false);
776 }
777
778
779 bool InsetInfo::forceLTR(OutputParams const &) const
780 {
781         return params_.force_ltr;
782 }
783
784
785 bool InsetInfo::forceLocalFontSwitch() const
786 {
787         return params_.type == InsetInfoParams::MENU_INFO
788                 || params_.type == InsetInfoParams::SHORTCUTS_INFO
789                 || params_.type == InsetInfoParams::SHORTCUT_INFO
790                 || params_.type == InsetInfoParams::L7N_INFO;
791 }
792
793
794 void InsetInfo::metrics(MetricsInfo & mi, Dimension & dim) const
795 {
796         const_cast<InsetInfo *>(this)->build();
797         InsetCollapsible::metrics(mi, dim);
798 }
799
800
801 void InsetInfo::draw(PainterInfo & pi, int x, int y) const
802 {
803         Changer chg = changeVar(lyxrc.mark_foreign_language, false);
804         InsetCollapsible::draw(pi, x, y);
805 }
806
807 void InsetInfo::updateBuffer(ParIterator const & it, UpdateType utype, bool const deleted)
808
809 {
810         // If the Buffer is a clone, then we neither need nor want to do any
811         // of what follows. We want, rather, just to inherit how things were
812         // in the original Buffer. This is especially important for VCS.
813         // Otherwise, we could in principle have different settings here
814         // than in the Buffer we were exporting.
815         // However, we need to check whether the inset is in an intitle
816         // context.
817         if (buffer().isClone()) {
818                 InsetText::checkIntitleContext(it);
819                 return;
820         }
821         BufferParams const & bp = buffer().params();
822         params_.lang = it.paragraph().getFontSettings(bp, it.pos()).language();
823         InsetCollapsible::updateBuffer(it, utype, deleted);
824 }
825
826
827 void InsetInfo::build()
828 {
829         // If the Buffer is a clone, then we neither need nor want to do any
830         // of what follows. We want, rather, just to inherit how things were
831         // in the original Buffer. This is especially important for VCS.
832         // Otherwise, we could in principle have different settings here
833         // than in the Buffer we were exporting.
834         if (buffer().isClone())
835                 return;
836
837         Language const * tryguilang = languages.getFromCode(Messages::guiLanguage());
838         // Some info insets use the language of the GUI (if available)
839         Language const * guilang = tryguilang ? tryguilang : params_.lang;
840
841         params_.force_ltr = !params_.lang->rightToLeft();
842         // This is just to get the string into the po files
843         docstring gui;
844         switch (params_.type) {
845         case InsetInfoParams::UNKNOWN_INFO:
846                 gui = _("Unknown Info!");
847                 info(from_ascii("Unknown Info!"), params_.lang);
848                 initialized_ = false;
849                 break;
850         case InsetInfoParams::SHORTCUT_INFO:
851         case InsetInfoParams::SHORTCUTS_INFO: {
852                 // shortcuts can change, so we need to re-do this each time
853                 FuncRequest const func = lyxaction.lookupFunc(params_.name);
854                 if (func.action() == LFUN_UNKNOWN_ACTION) {
855                         gui = _("Unknown action %1$s");
856                         error(from_ascii("Unknown action %1$s"), params_.lang);
857                         break;
858                 }
859                 KeyMap::Bindings bindings = theTopLevelKeymap().findBindings(func);
860                 if (bindings.empty()) {
861                         gui = _("undefined");
862                         info(from_ascii("undefined"), params_.lang);
863                         break;
864                 }
865                 docstring sequence;
866                 docstring seq_untranslated;
867                 if (params_.type == InsetInfoParams::SHORTCUT_INFO) {
868                         sequence = bindings.begin()->print(KeySequence::ForGui);
869                         seq_untranslated = bindings.begin()->print(KeySequence::ForGui, true);
870                 } else {
871                         sequence = theTopLevelKeymap().printBindings(func, KeySequence::ForGui);
872                         seq_untranslated = theTopLevelKeymap().printBindings(func, KeySequence::ForGui, true);
873                 }
874                 // QKeySequence returns special characters for keys on the mac
875                 // Since these are not included in many fonts, we
876                 // re-translate them to textual names (see #10641)
877                 odocstringstream ods;
878                 string const lcode = params_.lang->code();
879                 docstring trans;
880                 bool is_translated = sequence != seq_untranslated;
881                 for (char_type const c : sequence) {
882                         switch(c) {
883                         case 0x21b5://Return
884                                 gui = _("Return[[Key]]");
885                                 is_translated = translateString(from_ascii("Return[[Key]]"), trans, lcode);
886                                 ods << trans;
887                                 break;
888                         case 0x21b9://Tab both directions (Win)
889                                 gui = _("Tab[[Key]]");
890                                 is_translated = translateString(from_ascii("Tab[[Key]]"), trans, lcode);
891                                 ods << trans;
892                                 break;
893                         case 0x21de://Qt::Key_PageUp
894                                 gui = _("PgUp");
895                                 is_translated = translateString(from_ascii("PgUp"), trans, lcode);
896                                 ods << trans;
897                                 break;
898                         case 0x21df://Qt::Key_PageDown
899                                 gui = _("PgDown");
900                                 is_translated = translateString(from_ascii("PgDown"), trans, lcode);
901                                 ods << trans;
902                                 break;
903                         case 0x21e4://Qt::Key_Backtab
904                                 gui = _("Backtab");
905                                 is_translated = translateString(from_ascii("Backtab"), trans, lcode);
906                                 ods << trans;
907                                 break;
908                         case 0x21e5://Qt::Key_Tab
909                                 gui = _("Tab");
910                                 is_translated = translateString(from_ascii("Tab"), trans, lcode);
911                                 ods << trans;
912                                 break;
913                         case 0x21e7://Shift
914                                 gui = _("Shift");
915                                 is_translated = translateString(from_ascii("Shift"), trans, lcode);
916                                 ods << trans;
917                                 break;
918                         case 0x21ea://Qt::Key_CapsLock
919                                 gui = _("CapsLock");
920                                 is_translated = translateString(from_ascii("CapsLock"), trans, lcode);
921                                 ods << trans;
922                                 break;
923                         case 0x2303://Control
924                                 gui = _("Control[[Key]]");
925                                 is_translated = translateString(from_ascii("Control[[Key]]"), trans, lcode);
926                                 ods << trans;
927                                 break;
928                         case 0x2318://CMD
929                                 gui = _("Command[[Key]]");
930                                 is_translated = translateString(from_ascii("Command[[Key]]"), trans, lcode);
931                                 ods << trans;
932                                 break;
933                         case 0x2324://Qt::Key_Enter
934                                 gui = _("Return[[Key]]");
935                                 is_translated = translateString(from_ascii("Return[[Key]]"), trans, lcode);
936                                 ods << trans;
937                                 break;
938                         case 0x2325://Option key
939                                 gui = _("Option[[Key]]");
940                                 is_translated = translateString(from_ascii("Option[[Key]]"), trans, lcode);
941                                 ods << trans;
942                                 break;
943                         case 0x2326://Qt::Key_Delete
944                                 gui = _("Delete[[Key]]");
945                                 is_translated = translateString(from_ascii("Delete[[Key]]"), trans, lcode);
946                                 ods << trans;
947                                 break;
948                         case 0x232b://Qt::Key_Backspace
949                                 gui = _("Fn+Del");
950                                 is_translated = translateString(from_ascii("Fn+Del"), trans, lcode);
951                                 ods << trans;
952                                 break;
953                         case 0x238b://Qt::Key_Escape
954                                 gui = _("Esc");
955                                 is_translated = translateString(from_ascii("Esc"), trans, lcode);
956                                 ods << trans;
957                                 break;
958                         default:
959                                 ods.put(c);
960                         }
961                 }
962                 setText(ods.str(), is_translated ? guilang : nullptr);
963                 params_.force_ltr = !is_translated || (!guilang->rightToLeft() && !params_.lang->rightToLeft());
964                 break;
965         }
966         case InsetInfoParams::LYXRC_INFO: {
967                 // this information could change, if the preferences are changed,
968                 // so we will recalculate each time through.
969                 ostringstream oss;
970                 if (params_.name.empty()) {
971                         gui = _("undefined");
972                         info(from_ascii("undefined"), params_.lang);
973                         break;
974                 }
975                 // FIXME this uses the serialization mechanism to get the info
976                 // we want, which i guess works but is a bit strange.
977                 lyxrc.write(oss, true, params_.name);
978                 string result = oss.str();
979                 if (result.size() < 2) {
980                         gui = _("undefined");
981                         info(from_ascii("undefined"), params_.lang);
982                         break;
983                 }
984                 string::size_type loc = result.rfind("\n", result.size() - 2);
985                 loc = loc == string::npos ? 0 : loc + 1;
986                 if (result.size() < loc + params_.name.size() + 1
987                           || result.substr(loc + 1, params_.name.size()) != params_.name) {
988                         gui = _("undefined");
989                         info(from_ascii("undefined"), params_.lang);
990                         break;
991                 }
992                 // remove leading comments and \\name and space
993                 result = result.substr(loc + params_.name.size() + 2);
994
995                 // remove \n and ""
996                 result = rtrim(result, "\n");
997                 result = trim(result, "\"");
998                 gui = _("not set");
999                 if (result.empty())
1000                         result = "not set";
1001                 setText(from_utf8(result), params_.lang);
1002                 break;
1003         }
1004         case InsetInfoParams::PACKAGE_INFO:
1005                 // only need to do this once.
1006                 if (initialized_)
1007                         break;
1008                 // check in packages.lst
1009                 bool available;
1010                 // we also allow version check with version separated by blank
1011                 if (contains(params_.name, ' ')) {
1012                         string name;
1013                         string const version = split(params_.name, name, ' ');
1014                         int const y = convert<int>(version.substr(0,4));
1015                         int const m = convert<int>(version.substr(4,2));
1016                         int const d = convert<int>(version.substr(6,2));
1017                         available = LaTeXFeatures::isAvailableAtLeastFrom(name, y, m, d);
1018                 } else
1019                         available = LaTeXFeatures::isAvailable(params_.name);
1020
1021                 if (available) {
1022                         gui = _("yes");
1023                         info(from_ascii("yes"), params_.lang);
1024                 } else {
1025                         gui = _("no");
1026                         info(from_ascii("no"), params_.lang);
1027                 }
1028                 initialized_ = true;
1029                 break;
1030
1031         case InsetInfoParams::TEXTCLASS_INFO: {
1032                 // the TextClass can change
1033                 LayoutFileList const & list = LayoutFileList::get();
1034                 bool available = false;
1035                 // params_.name is the class name
1036                 if (list.haveClass(params_.name))
1037                         available = list[params_.name].isTeXClassAvailable();
1038                 if (available) {
1039                         gui = _("yes");
1040                         info(from_ascii("yes"), params_.lang);
1041                 } else {
1042                         gui = _("no");
1043                         info(from_ascii("no"), params_.lang);
1044                 }
1045                 break;
1046         }
1047         case InsetInfoParams::MENU_INFO: {
1048                 // only need to do this once.
1049                 if (initialized_)
1050                         break;
1051                 docstring_list names;
1052                 FuncRequest func = lyxaction.lookupFunc(params_.name);
1053                 if (func.action() == LFUN_UNKNOWN_ACTION) {
1054                         gui = _("Unknown action %1$s");
1055                         error(from_ascii("Unknown action %1$s"), params_.lang);
1056                         break;
1057                 }
1058                 if (func.action() == LFUN_BUFFER_VIEW || func.action() == LFUN_BUFFER_UPDATE)
1059                         // The default output format is in the menu without argument,
1060                         // so strip it here.
1061                         if (func.argument() == from_ascii(buffer().params().getDefaultOutputFormat()))
1062                                 func = FuncRequest(func.action());
1063                 // iterate through the menubackend to find it
1064                 if (!theApp()) {
1065                         gui = _("Can't determine menu entry for action %1$s in batch mode");
1066                         error(from_ascii("Can't determine menu entry for action %1$s in batch mode"), params_.lang);
1067                         initialized_ = true;
1068                         break;
1069                 }
1070                 // and we will not keep trying if we fail
1071                 initialized_ = theApp()->hasBufferView();
1072                 if (!theApp()->searchMenu(func, names)) {
1073                         gui = _("No menu entry for action %1$s");
1074                         error(from_ascii("No menu entry for action %1$s"), params_.lang);
1075                         break;
1076                 }
1077                 // if found, return its path.
1078                 clear();
1079                 Paragraph & par = paragraphs().front();
1080                 Font const f(inherit_font, guilang);
1081                 params_.force_ltr = !guilang->rightToLeft();
1082                 //Font fu = f;
1083                 //fu.fontInfo().setUnderbar(FONT_ON);
1084                 for (docstring const & name : names) {
1085                         // do not insert > for the top level menu item
1086                         if (&name != &names.front())
1087                                 par.insertInset(par.size(), new InsetSpecialChar(InsetSpecialChar::MENU_SEPARATOR),
1088                                                 f, Change(Change::UNCHANGED));
1089                         //FIXME: add proper underlines here. This
1090                         // involves rewriting searchMenu used above to
1091                         // return a vector of menus. If we do not do
1092                         // that, we might as well use below
1093                         // Paragraph::insert on each string (JMarc)
1094                         for (char_type c : name)
1095                                 par.insertChar(par.size(), c, f, Change(Change::UNCHANGED));
1096                 }
1097                 break;
1098         }
1099         case InsetInfoParams::L7N_INFO: {
1100                 docstring locstring = _(params_.name);
1101                 // Remove trailing colons
1102                 locstring = rtrim(locstring, ":");
1103                 // Remove menu accelerators
1104                 if (contains(locstring, from_ascii("|"))) {
1105                         docstring nlocstring;
1106                         rsplit(locstring, nlocstring, '|');
1107                         locstring = nlocstring;
1108                 }
1109                 // Remove Qt accelerators, but keep literal ampersands
1110                 locstring = subst(locstring, from_ascii(" & "), from_ascii("</amp;>"));
1111                 locstring = subst(locstring, from_ascii("&"), docstring());
1112                 locstring = subst(locstring, from_ascii("</amp;>"), from_ascii(" & "));
1113                 setText(locstring, guilang);
1114                 params_.force_ltr = !guilang->rightToLeft() && !params_.lang->rightToLeft();
1115                 break;
1116         }
1117         case InsetInfoParams::ICON_INFO: {
1118                 // only need to do this once.
1119                 if (initialized_)
1120                         break;
1121                 // and we will not keep trying if we fail
1122                 initialized_ = true;
1123                 FuncRequest func = lyxaction.lookupFunc(params_.name);
1124                 docstring icon_name = frontend::Application::iconName(func, true);
1125                 FileName file(to_utf8(icon_name));
1126                 if (file.onlyFileNameWithoutExt() == "unknown") {
1127                         string dir = "images";
1128                         FileName file2(imageLibFileSearch(dir, params_.name, "svgz,png"));
1129                         if (!file2.empty())
1130                                 file = file2;
1131                 }
1132                 if (!file.exists())
1133                         break;
1134                 int percent_scale = 100;
1135                 if (use_gui) {
1136                         // Compute the scale factor for the icon such that its
1137                         // width on screen is equal to 1em in pixels.
1138                         // The scale factor is rounded to the integer nearest
1139                         // to the float value of the ratio 100*iconsize/imgsize.
1140                         int imgsize = QImage(toqstr(file.absFileName())).width();
1141                         if (imgsize > 0) {
1142                                 int iconsize = Length(1, Length::EM).inPixels(1);
1143                                 percent_scale = (100 * iconsize + imgsize / 2)/imgsize;
1144                         }
1145                 }
1146                 InsetGraphicsTight * inset = new InsetGraphicsTight(buffer_);
1147                 InsetGraphicsParams igp;
1148                 igp.filename = file;
1149                 igp.lyxscale = percent_scale;
1150                 igp.scale = string();
1151                 igp.width = Length(1, Length::EM);
1152                 if (contains(file.absoluteFilePath(), from_ascii("math"))
1153                     || contains(file.absoluteFilePath(), from_ascii("ert-insert"))
1154                     || suffixIs(file.onlyPath().absoluteFilePath(), from_ascii("ipa")))
1155                         igp.darkModeSensitive = true;
1156                 inset->setParams(igp);
1157                 clear();
1158                 Font const f(inherit_font, params_.lang);
1159                 paragraphs().front().insertInset(0, inset, f,
1160                                                  Change(Change::UNCHANGED));
1161                 break;
1162         }
1163         case InsetInfoParams::BUFFER_INFO: {
1164                 // this could all change, so we will recalculate each time
1165                 if (params_.name == "name")
1166                         setText(from_utf8(buffer().fileName().onlyFileName()), params_.lang);
1167                 else if (params_.name == "name-noext")
1168                         setText(from_utf8(buffer().fileName().onlyFileNameWithoutExt()), params_.lang);
1169                 else if (params_.name == "path")
1170                         setText(from_utf8(os::latex_path(buffer().filePath())), params_.lang);
1171                 else if (params_.name == "class")
1172                         setText(from_utf8(buffer().params().documentClass().name()), params_.lang);
1173                 break;
1174         }
1175         case InsetInfoParams::VCS_INFO: {
1176                 // this information could change, in principle, so we will 
1177                 // recalculate each time through
1178                 if (!buffer().lyxvc().inUse()) {
1179                         gui = _("No version control!");
1180                         info(from_ascii("No version control!"), params_.lang);
1181                         break;
1182                 }
1183                 LyXVC::RevisionInfo itype = LyXVC::Unknown;
1184                 if (params_.name == "revision")
1185                         itype = LyXVC::File;
1186                 else if (params_.name == "revision-abbrev")
1187                         itype = LyXVC::FileAbbrev;
1188                 else if (params_.name == "tree-revision")
1189                         itype = LyXVC::Tree;
1190                 else if (params_.name == "author")
1191                         itype = LyXVC::Author;
1192                 else if (params_.name == "time")
1193                         itype = LyXVC::Time;
1194                 else if (params_.name == "date")
1195                         itype = LyXVC::Date;
1196                 string binfo = buffer().lyxvc().revisionInfo(itype);
1197                 if (binfo.empty()) {
1198                         gui = _("%1$s[[vcs data]] unknown");
1199                         error(from_ascii("%1$s[[vcs data]] unknown"), params_.lang);
1200                 } else
1201                         setText(from_utf8(binfo), params_.lang);
1202                 break;
1203         }
1204         case InsetInfoParams::LYX_INFO:
1205                 // only need to do this once.
1206                 if (initialized_)
1207                         break;
1208                 if (params_.name == "version")
1209                         setText(from_ascii(lyx_version), params_.lang);
1210                 else if (params_.name == "layoutformat")
1211                         setText(convert<docstring>(LAYOUT_FORMAT), params_.lang);
1212                 initialized_ = true;
1213                 break;
1214         case InsetInfoParams::DATE_INFO:
1215         case InsetInfoParams::MODDATE_INFO:
1216         case InsetInfoParams::FIXDATE_INFO: {
1217                 string date_format = params_.name;
1218                 string const date_specifier = (params_.type == InsetInfoParams::FIXDATE_INFO
1219                                                && contains(params_.name, '@'))
1220                                 ? split(params_.name, date_format, '@') : string();
1221                 QDate date;
1222                 if (params_.type == InsetInfoParams::MODDATE_INFO)
1223 #if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
1224                         date = QDateTime::fromSecsSinceEpoch(buffer().fileName().lastModified()).date();
1225 #else
1226                         date = QDateTime::fromTime_t(buffer().fileName().lastModified()).date();
1227 #endif
1228                 else if (params_.type == InsetInfoParams::FIXDATE_INFO && !date_specifier.empty())
1229                         date = QDate::fromString(toqstr(date_specifier), Qt::ISODate);
1230                 else
1231                         date = QDate::currentDate();
1232                 setText(params_.getDate(date_format, date), params_.lang);
1233                 break;
1234         }
1235         case InsetInfoParams::TIME_INFO:
1236         case InsetInfoParams::MODTIME_INFO:
1237         case InsetInfoParams::FIXTIME_INFO: {
1238                 string time_format = params_.name;
1239                 string const time_specifier = (params_.type == InsetInfoParams::FIXTIME_INFO
1240                                                && contains(params_.name, '@'))
1241                                 ? split(params_.name, time_format, '@') : string();
1242                 QTime time;
1243                 if (params_.type == InsetInfoParams::MODTIME_INFO)
1244 #if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
1245                         time = QDateTime::fromSecsSinceEpoch(buffer().fileName().lastModified()).time();
1246 #else
1247                         time = QDateTime::fromTime_t(buffer().fileName().lastModified()).time();
1248 #endif
1249                 else if (params_.type == InsetInfoParams::FIXTIME_INFO && !time_specifier.empty())
1250                         time = QTime::fromString(toqstr(time_specifier), Qt::ISODate);
1251                 else
1252                         time = QTime::currentTime();
1253                 setText(params_.getTime(time_format, time), params_.lang);
1254                 break;
1255         }
1256         }
1257
1258         // Just to do something with that string
1259         LYXERR(Debug::INFO, "info inset text: " << gui);
1260 }
1261
1262
1263 void InsetInfo::validate(LaTeXFeatures & features) const
1264 {
1265         const_cast<InsetInfo *>(this)->build();
1266         InsetCollapsible::validate(features);
1267 }
1268
1269
1270 string InsetInfo::contextMenu(BufferView const &, int, int) const
1271 {
1272         //FIXME: We override the implementation of InsetCollapsible,
1273         //because this inset is not a collapsible inset.
1274         return contextMenuName();
1275 }
1276
1277
1278 string InsetInfo::contextMenuName() const
1279 {
1280         return "context-info";
1281 }
1282
1283
1284 } // namespace lyx