]> git.lyx.org Git - lyx.git/blob - src/LyXFunc.cpp
Kornel's gcc compil fix.
[lyx.git] / src / LyXFunc.cpp
1 /**
2  * \file LyXFunc.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Alfredo Braunstein
7  * \author Lars Gullik Bjønnes
8  * \author Jean-Marc Lasgouttes
9  * \author Angus Leeming
10  * \author John Levon
11  * \author André Pönitz
12  * \author Allan Rae
13  * \author Dekel Tsur
14  * \author Martin Vermeer
15  * \author Jürgen Vigna
16  *
17  * Full author contact details are available in file CREDITS.
18  */
19
20 #include <config.h>
21
22 #include "LyXFunc.h"
23
24 #include "LayoutFile.h"
25 #include "BranchList.h"
26 #include "buffer_funcs.h"
27 #include "Buffer.h"
28 #include "BufferList.h"
29 #include "BufferParams.h"
30 #include "BufferView.h"
31 #include "CmdDef.h"
32 #include "Color.h"
33 #include "Converter.h"
34 #include "Cursor.h"
35 #include "CutAndPaste.h"
36 #include "DispatchResult.h"
37 #include "Encoding.h"
38 #include "ErrorList.h"
39 #include "Format.h"
40 #include "FuncRequest.h"
41 #include "FuncStatus.h"
42 #include "InsetIterator.h"
43 #include "Intl.h"
44 #include "KeyMap.h"
45 #include "Language.h"
46 #include "Lexer.h"
47 #include "LyXAction.h"
48 #include "lyxfind.h"
49 #include "LyX.h"
50 #include "LyXRC.h"
51 #include "LyXVC.h"
52 #include "Paragraph.h"
53 #include "ParagraphParameters.h"
54 #include "ParIterator.h"
55 #include "Row.h"
56 #include "Server.h"
57 #include "Session.h"
58 #include "SpellChecker.h"
59
60 #include "insets/InsetBox.h"
61 #include "insets/InsetBranch.h"
62 #include "insets/InsetCommand.h"
63 #include "insets/InsetERT.h"
64 #include "insets/InsetExternal.h"
65 #include "insets/InsetFloat.h"
66 #include "insets/InsetGraphics.h"
67 #include "insets/InsetInclude.h"
68 #include "insets/InsetListings.h"
69 #include "insets/InsetNote.h"
70 #include "insets/InsetPhantom.h"
71 #include "insets/InsetSpace.h"
72 #include "insets/InsetTabular.h"
73 #include "insets/InsetVSpace.h"
74 #include "insets/InsetWrap.h"
75
76 #include "frontends/alert.h"
77 #include "frontends/Application.h"
78 #include "frontends/KeySymbol.h"
79 #include "frontends/LyXView.h"
80 #include "frontends/Selection.h"
81
82 #include "support/debug.h"
83 #include "support/environment.h"
84 #include "support/FileName.h"
85 #include "support/filetools.h"
86 #include "support/gettext.h"
87 #include "support/lstrings.h"
88 #include "support/Path.h"
89 #include "support/Package.h"
90 #include "support/Systemcall.h"
91 #include "support/convert.h"
92 #include "support/os.h"
93
94 #include <sstream>
95 #include <vector>
96
97 using namespace std;
98 using namespace lyx::support;
99
100 namespace lyx {
101
102 using frontend::LyXView;
103
104 namespace Alert = frontend::Alert;
105
106 namespace {
107
108
109 // This function runs "configure" and then rereads lyx.defaults to
110 // reconfigure the automatic settings.
111 void reconfigure(LyXView * lv, string const & option)
112 {
113         // emit message signal.
114         if (lv)
115                 lv->message(_("Running configure..."));
116
117         // Run configure in user lyx directory
118         PathChanger p(package().user_support());
119         string configure_command = package().configure_command();
120         configure_command += option;
121         Systemcall one;
122         int ret = one.startscript(Systemcall::Wait, configure_command);
123         p.pop();
124         // emit message signal.
125         if (lv)
126                 lv->message(_("Reloading configuration..."));
127         lyxrc.read(libFileSearch(string(), "lyxrc.defaults"));
128         // Re-read packages.lst
129         LaTeXFeatures::getAvailable();
130
131         if (ret)
132                 Alert::information(_("System reconfiguration failed"),
133                            _("The system reconfiguration has failed.\n"
134                                   "Default textclass is used but LyX may "
135                                   "not be able to work properly.\n"
136                                   "Please reconfigure again if needed."));
137         else
138
139                 Alert::information(_("System reconfigured"),
140                            _("The system has been reconfigured.\n"
141                              "You need to restart LyX to make use of any\n"
142                              "updated document class specifications."));
143 }
144
145 }
146
147
148 LyXFunc::LyXFunc()
149         : encoded_last_key(0), meta_fake_bit(NoModifier)
150 {
151 }
152
153
154 void LyXFunc::initKeySequences(KeyMap * kb)
155 {
156         keyseq = KeySequence(kb, kb);
157         cancel_meta_seq = KeySequence(kb, kb);
158 }
159
160
161 void LyXFunc::handleKeyFunc(FuncCode action)
162 {
163         char_type c = encoded_last_key;
164
165         if (keyseq.length())
166                 c = 0;
167         LyXView * lv = theApp()->currentWindow();
168         LASSERT(lv && lv->currentBufferView(), /**/);
169         BufferView * bv = lv->currentBufferView();
170         bv->getIntl().getTransManager().deadkey(
171                 c, get_accent(action).accent, bv->cursor().innerText(),
172                 bv->cursor());
173         // Need to clear, in case the minibuffer calls these
174         // actions
175         keyseq.clear();
176         // copied verbatim from do_accent_char
177         bv->cursor().resetAnchor();
178         bv->processUpdateFlags(Update::FitCursor);
179 }
180
181 //FIXME: bookmark handling is a frontend issue. This code should be transferred
182 // to GuiView and be GuiView and be window dependent.
183 void LyXFunc::gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer)
184 {
185         LyXView * lv = theApp()->currentWindow();
186         LASSERT(lv, /**/);
187         if (!theSession().bookmarks().isValid(idx))
188                 return;
189         BookmarksSection::Bookmark const & bm = theSession().bookmarks().bookmark(idx);
190         LASSERT(!bm.filename.empty(), /**/);
191         string const file = bm.filename.absFilename();
192         // if the file is not opened, open it.
193         if (!theBufferList().exists(bm.filename)) {
194                 if (openFile)
195                         dispatch(FuncRequest(LFUN_FILE_OPEN, file));
196                 else
197                         return;
198         }
199         // open may fail, so we need to test it again
200         if (!theBufferList().exists(bm.filename))
201                 return;
202
203         // bm can be changed when saving
204         BookmarksSection::Bookmark tmp = bm;
205
206         // Special case idx == 0 used for back-from-back jump navigation
207         if (idx == 0)
208                 dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"));
209
210         // if the current buffer is not that one, switch to it.
211         if (!lv->documentBufferView()
212                 || lv->documentBufferView()->buffer().fileName() != tmp.filename) {
213                 if (!switchToBuffer)
214                         return;
215                 dispatch(FuncRequest(LFUN_BUFFER_SWITCH, file));
216         }
217
218         // moveToPosition try paragraph id first and then paragraph (pit, pos).
219         if (!lv->documentBufferView()->moveToPosition(
220                 tmp.bottom_pit, tmp.bottom_pos, tmp.top_id, tmp.top_pos))
221                 return;
222
223         // bm changed
224         if (idx == 0)
225                 return;
226
227         // Cursor jump succeeded!
228         Cursor const & cur = lv->documentBufferView()->cursor();
229         pit_type new_pit = cur.pit();
230         pos_type new_pos = cur.pos();
231         int new_id = cur.paragraph().id();
232
233         // if bottom_pit, bottom_pos or top_id has been changed, update bookmark
234         // see http://bugzilla.lyx.org/show_bug.cgi?id=3092
235         if (bm.bottom_pit != new_pit || bm.bottom_pos != new_pos 
236                 || bm.top_id != new_id) {
237                 const_cast<BookmarksSection::Bookmark &>(bm).updatePos(
238                         new_pit, new_pos, new_id);
239         }
240 }
241
242
243 void LyXFunc::processKeySym(KeySymbol const & keysym, KeyModifier state)
244 {
245         LYXERR(Debug::KEY, "KeySym is " << keysym.getSymbolName());
246
247         LyXView * lv = theApp()->currentWindow();
248
249         // Do nothing if we have nothing (JMarc)
250         if (!keysym.isOK()) {
251                 LYXERR(Debug::KEY, "Empty kbd action (probably composing)");
252                 lv->restartCursor();
253                 return;
254         }
255
256         if (keysym.isModifier()) {
257                 LYXERR(Debug::KEY, "isModifier true");
258                 if (lv)
259                         lv->restartCursor();
260                 return;
261         }
262
263         //Encoding const * encoding = lv->documentBufferView()->cursor().getEncoding();
264         //encoded_last_key = keysym.getISOEncoded(encoding ? encoding->name() : "");
265         // FIXME: encoded_last_key shadows the member variable of the same
266         // name. Is that intended?
267         char_type encoded_last_key = keysym.getUCSEncoded();
268
269         // Do a one-deep top-level lookup for
270         // cancel and meta-fake keys. RVDK_PATCH_5
271         cancel_meta_seq.reset();
272
273         FuncRequest func = cancel_meta_seq.addkey(keysym, state);
274         LYXERR(Debug::KEY, "action first set to [" << func.action << ']');
275
276         // When not cancel or meta-fake, do the normal lookup.
277         // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
278         // Mostly, meta_fake_bit = NoModifier. RVDK_PATCH_5.
279         if ((func.action != LFUN_CANCEL) && (func.action != LFUN_META_PREFIX)) {
280                 // remove Caps Lock and Mod2 as a modifiers
281                 func = keyseq.addkey(keysym, (state | meta_fake_bit));
282                 LYXERR(Debug::KEY, "action now set to [" << func.action << ']');
283         }
284
285         // Dont remove this unless you know what you are doing.
286         meta_fake_bit = NoModifier;
287
288         // Can this happen now ?
289         if (func.action == LFUN_NOACTION)
290                 func = FuncRequest(LFUN_COMMAND_PREFIX);
291
292         LYXERR(Debug::KEY, " Key [action=" << func.action << "]["
293                 << keyseq.print(KeySequence::Portable) << ']');
294
295         // already here we know if it any point in going further
296         // why not return already here if action == -1 and
297         // num_bytes == 0? (Lgb)
298
299         if (keyseq.length() > 1)
300                 lv->message(keyseq.print(KeySequence::ForGui));
301
302
303         // Maybe user can only reach the key via holding down shift.
304         // Let's see. But only if shift is the only modifier
305         if (func.action == LFUN_UNKNOWN_ACTION && state == ShiftModifier) {
306                 LYXERR(Debug::KEY, "Trying without shift");
307                 func = keyseq.addkey(keysym, NoModifier);
308                 LYXERR(Debug::KEY, "Action now " << func.action);
309         }
310
311         if (func.action == LFUN_UNKNOWN_ACTION) {
312                 // Hmm, we didn't match any of the keysequences. See
313                 // if it's normal insertable text not already covered
314                 // by a binding
315                 if (keysym.isText() && keyseq.length() == 1) {
316                         LYXERR(Debug::KEY, "isText() is true, inserting.");
317                         func = FuncRequest(LFUN_SELF_INSERT,
318                                            FuncRequest::KEYBOARD);
319                 } else {
320                         LYXERR(Debug::KEY, "Unknown, !isText() - giving up");
321                         lv->message(_("Unknown function."));
322                         lv->restartCursor();
323                         return;
324                 }
325         }
326
327         if (func.action == LFUN_SELF_INSERT) {
328                 if (encoded_last_key != 0) {
329                         docstring const arg(1, encoded_last_key);
330                         dispatch(FuncRequest(LFUN_SELF_INSERT, arg,
331                                              FuncRequest::KEYBOARD));
332                         LYXERR(Debug::KEY, "SelfInsert arg[`" << to_utf8(arg) << "']");
333                 }
334         } else {
335                 dispatch(func);
336                 if (!lv)
337                         return;
338         }
339 }
340
341
342 FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
343 {
344         //lyxerr << "LyXFunc::getStatus: cmd: " << cmd << endl;
345         FuncStatus flag;
346
347         if (cmd.action == LFUN_NOACTION) {
348                 flag.message(from_utf8(N_("Nothing to do")));
349                 flag.setEnabled(false);
350                 return flag;
351         }
352
353         switch (cmd.action) {
354         case LFUN_UNKNOWN_ACTION:
355                 flag.unknown(true);
356                 flag.setEnabled(false);
357                 break;
358
359         default:
360                 break;
361         }
362
363         if (flag.unknown()) {
364                 flag.message(from_utf8(N_("Unknown action")));
365                 return flag;
366         }
367
368         if (!flag.enabled()) {
369                 if (flag.message().empty())
370                         flag.message(from_utf8(N_("Command disabled")));
371                 return flag;
372         }
373
374         // I would really like to avoid having this switch and rather try to
375         // encode this in the function itself.
376         // -- And I'd rather let an inset decide which LFUNs it is willing
377         // to handle (Andre')
378         bool enable = true;
379         switch (cmd.action) {
380
381         case LFUN_CITATION_INSERT: {
382                 FuncRequest fr(LFUN_INSET_INSERT, "citation");
383                 enable = getStatus(fr).enabled();
384                 break;
385         }
386         
387         // This could be used for the no-GUI version. The GUI version is handled in
388         // LyXView::getStatus(). See above.
389         /*
390         case LFUN_BUFFER_WRITE:
391         case LFUN_BUFFER_WRITE_AS: {
392                 Buffer * b = theBufferList().getBuffer(FileName(cmd.getArg(0)));
393                 enable = b && (b->isUnnamed() || !b->isClean());
394                 break;
395         }
396         */
397
398         case LFUN_BOOKMARK_GOTO: {
399                 const unsigned int num = convert<unsigned int>(to_utf8(cmd.argument()));
400                 enable = theSession().bookmarks().isValid(num);
401                 break;
402         }
403
404         case LFUN_BOOKMARK_CLEAR:
405                 enable = theSession().bookmarks().hasValid();
406                 break;
407
408         // this one is difficult to get right. As a half-baked
409         // solution, we consider only the first action of the sequence
410         case LFUN_COMMAND_SEQUENCE: {
411                 // argument contains ';'-terminated commands
412                 string const firstcmd = token(to_utf8(cmd.argument()), ';', 0);
413                 FuncRequest func(lyxaction.lookupFunc(firstcmd));
414                 func.origin = cmd.origin;
415                 flag = getStatus(func);
416                 break;
417         }
418
419         // we want to check if at least one of these is enabled
420         case LFUN_COMMAND_ALTERNATIVES: {
421                 // argument contains ';'-terminated commands
422                 string arg = to_utf8(cmd.argument());
423                 while (!arg.empty()) {
424                         string first;
425                         arg = split(arg, first, ';');
426                         FuncRequest func(lyxaction.lookupFunc(first));
427                         func.origin = cmd.origin;
428                         flag = getStatus(func);
429                         // if this one is enabled, the whole thing is
430                         if (flag.enabled())
431                                 break;
432                 }
433                 break;
434         }
435
436         case LFUN_CALL: {
437                 FuncRequest func;
438                 string name = to_utf8(cmd.argument());
439                 if (theTopLevelCmdDef().lock(name, func)) {
440                         func.origin = cmd.origin;
441                         flag = getStatus(func);
442                         theTopLevelCmdDef().release(name);
443                 } else {
444                         // catch recursion or unknown command
445                         // definition. all operations until the
446                         // recursion or unknown command definition
447                         // occurs are performed, so set the state to
448                         // enabled
449                         enable = true;
450                 }
451                 break;
452         }
453
454         case LFUN_COMMAND_PREFIX:
455         case LFUN_CANCEL:
456         case LFUN_META_PREFIX:
457         case LFUN_RECONFIGURE:
458         case LFUN_DROP_LAYOUTS_CHOICE:
459         case LFUN_SERVER_GET_FILENAME:
460         case LFUN_SERVER_NOTIFY:
461         case LFUN_CURSOR_FOLLOWS_SCROLLBAR_TOGGLE:
462         case LFUN_REPEAT:
463         case LFUN_PREFERENCES_SAVE:
464         case LFUN_INSET_EDIT:
465         case LFUN_BUFFER_SAVE_AS_DEFAULT:
466         case LFUN_LYXRC_APPLY:
467                 // these are handled in our dispatch()
468                 break;
469
470         default:
471                 if (!theApp()) {
472                         enable = false;
473                         break;
474                 }
475                 if (theApp()->getStatus(cmd, flag))
476                         break;
477
478                 // Does the view know something?
479                 LyXView * lv = theApp()->currentWindow();
480                 if (!lv) {
481                         enable = false;
482                         break;
483                 }
484                 if (lv->getStatus(cmd, flag))
485                         break;
486
487                 BufferView * bv = lv->currentBufferView();
488                 BufferView * doc_bv = lv->documentBufferView();
489                 // If we do not have a BufferView, then other functions are disabled
490                 if (!bv) {
491                         enable = false;
492                         break;
493                 }
494                 // try the BufferView
495                 bool decided = bv->getStatus(cmd, flag);
496                 if (!decided)
497                         // try the Buffer
498                         decided = bv->buffer().getStatus(cmd, flag);
499                 if (!decided && doc_bv)
500                         // try the Document Buffer
501                         decided = doc_bv->buffer().getStatus(cmd, flag);
502         }
503
504         if (!enable)
505                 flag.setEnabled(false);
506
507         // the default error message if we disable the command
508         if (!flag.enabled() && flag.message().empty())
509                 flag.message(from_utf8(N_("Command disabled")));
510
511         return flag;
512 }
513
514
515 namespace {
516
517 void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new);
518
519 } //namespace anon
520
521
522 void LyXFunc::dispatch(FuncRequest const & cmd)
523 {
524         string const argument = to_utf8(cmd.argument());
525         FuncCode const action = cmd.action;
526
527         LYXERR(Debug::ACTION, "\nLyXFunc::dispatch: cmd: " << cmd);
528         //lyxerr << "LyXFunc::dispatch: cmd: " << cmd << endl;
529
530         // we have not done anything wrong yet.
531         errorstat = false;
532         dispatch_buffer.erase();
533
534         // redraw the screen at the end (first of the two drawing steps).
535         //This is done unless explicitely requested otherwise
536         Update::flags updateFlags = Update::FitCursor;
537
538         LyXView * lv = theApp()->currentWindow();
539
540         FuncStatus const flag = getStatus(cmd);
541         if (!flag.enabled()) {
542                 // We cannot use this function here
543                 LYXERR(Debug::ACTION, "LyXFunc::dispatch: "
544                        << lyxaction.getActionName(action)
545                        << " [" << action << "] is disabled at this location");
546                 setErrorMessage(flag.message());
547                 if (lv)
548                         lv->restartCursor();
549         } else {
550                 Buffer * buffer = 0;
551                 if (lv && lv->currentBufferView())
552                         buffer = &lv->currentBufferView()->buffer();
553                 switch (action) {
554
555                 case LFUN_COMMAND_PREFIX:
556                         LASSERT(lv, /**/);
557                         lv->message(keyseq.printOptions(true));
558                         break;
559
560                 case LFUN_CANCEL:
561                         LASSERT(lv && lv->currentBufferView(), /**/);
562                         keyseq.reset();
563                         meta_fake_bit = NoModifier;
564                         if (buffer)
565                                 // cancel any selection
566                                 dispatch(FuncRequest(LFUN_MARK_OFF));
567                         setMessage(from_ascii(N_("Cancel")));
568                         break;
569
570                 case LFUN_META_PREFIX:
571                         meta_fake_bit = AltModifier;
572                         setMessage(keyseq.print(KeySequence::ForGui));
573                         break;
574
575                 // --- Menus -----------------------------------------------
576                 case LFUN_RECONFIGURE:
577                         // argument is any additional parameter to the configure.py command
578                         reconfigure(lv, argument);
579                         break;
580
581                 // --- lyxserver commands ----------------------------
582                 case LFUN_SERVER_GET_FILENAME:
583                         LASSERT(lv && buffer, /**/);
584                         setMessage(from_utf8(buffer->absFileName()));
585                         LYXERR(Debug::INFO, "FNAME["
586                                 << buffer->absFileName() << ']');
587                         break;
588
589                 case LFUN_SERVER_NOTIFY:
590                         dispatch_buffer = keyseq.print(KeySequence::Portable);
591                         theServer().notifyClient(to_utf8(dispatch_buffer));
592                         break;
593
594                 case LFUN_DIALOG_SHOW_NEW_INSET: {
595                         LASSERT(lv, /**/);
596                         string const name = cmd.getArg(0);
597                         InsetCode code = insetCode(name);
598                         string data = trim(to_utf8(cmd.argument()).substr(name.size()));
599                         bool insetCodeOK = true;
600                         switch (code) {
601                         case BIBITEM_CODE:
602                         case BIBTEX_CODE:
603                         case INDEX_CODE:
604                         case LABEL_CODE:
605                         case NOMENCL_CODE:
606                         case NOMENCL_PRINT_CODE:
607                         case REF_CODE:
608                         case TOC_CODE:
609                         case HYPERLINK_CODE: {
610                                 InsetCommandParams p(code);
611                                 data = InsetCommand::params2string(name, p);
612                                 break;
613                         }
614                         case INCLUDE_CODE: {
615                                 // data is the include type: one of "include",
616                                 // "input", "verbatiminput" or "verbatiminput*"
617                                 if (data.empty())
618                                         // default type is requested
619                                         data = "include";
620                                 InsetCommandParams p(INCLUDE_CODE, data);
621                                 data = InsetCommand::params2string("include", p);
622                                 break;
623                         }
624                         case BOX_CODE: {
625                                 // \c data == "Boxed" || "Frameless" etc
626                                 InsetBoxParams p(data);
627                                 data = InsetBox::params2string(p);
628                                 break;
629                         }
630                         case BRANCH_CODE: {
631                                 InsetBranchParams p;
632                                 data = InsetBranch::params2string(p);
633                                 break;
634                         }
635                         case CITE_CODE: {
636                                 InsetCommandParams p(CITE_CODE);
637                                 data = InsetCommand::params2string(name, p);
638                                 break;
639                         }
640                         case ERT_CODE: {
641                                 data = InsetERT::params2string(InsetCollapsable::Open);
642                                 break;
643                         }
644                         case EXTERNAL_CODE: {
645                                 InsetExternalParams p;
646                                 data = InsetExternal::params2string(p, *buffer);
647                                 break;
648                         }
649                         case FLOAT_CODE:  {
650                                 InsetFloatParams p;
651                                 data = InsetFloat::params2string(p);
652                                 break;
653                         }
654                         case LISTINGS_CODE: {
655                                 InsetListingsParams p;
656                                 data = InsetListings::params2string(p);
657                                 break;
658                         }
659                         case GRAPHICS_CODE: {
660                                 InsetGraphicsParams p;
661                                 data = InsetGraphics::params2string(p, *buffer);
662                                 break;
663                         }
664                         case NOTE_CODE: {
665                                 InsetNoteParams p;
666                                 data = InsetNote::params2string(p);
667                                 break;
668                         }
669                         case PHANTOM_CODE: {
670                                 InsetPhantomParams p;
671                                 data = InsetPhantom::params2string(p);
672                                 break;
673                         }
674                         case SPACE_CODE: {
675                                 InsetSpaceParams p;
676                                 data = InsetSpace::params2string(p);
677                                 break;
678                         }
679                         case VSPACE_CODE: {
680                                 VSpace space;
681                                 data = InsetVSpace::params2string(space);
682                                 break;
683                         }
684                         case WRAP_CODE: {
685                                 InsetWrapParams p;
686                                 data = InsetWrap::params2string(p);
687                                 break;
688                         }
689                         default:
690                                 lyxerr << "Inset type '" << name << 
691                                         "' not recognized in LFUN_DIALOG_SHOW_NEW_INSET" <<  endl;
692                                 insetCodeOK = false;
693                                 break;
694                         } // end switch(code)
695                         if (insetCodeOK)
696                                 dispatch(FuncRequest(LFUN_DIALOG_SHOW, name + " " + data));
697                         break;
698                 }
699
700                 case LFUN_CITATION_INSERT: {
701                         LASSERT(lv, /**/);
702                         if (!argument.empty()) {
703                                 // we can have one optional argument, delimited by '|'
704                                 // citation-insert <key>|<text_before>
705                                 // this should be enhanced to also support text_after
706                                 // and citation style
707                                 string arg = argument;
708                                 string opt1;
709                                 if (contains(argument, "|")) {
710                                         arg = token(argument, '|', 0);
711                                         opt1 = token(argument, '|', 1);
712                                 }
713                                 InsetCommandParams icp(CITE_CODE);
714                                 icp["key"] = from_utf8(arg);
715                                 if (!opt1.empty())
716                                         icp["before"] = from_utf8(opt1);
717                                 string icstr = InsetCommand::params2string("citation", icp);
718                                 FuncRequest fr(LFUN_INSET_INSERT, icstr);
719                                 dispatch(fr);
720                         } else
721                                 dispatch(FuncRequest(LFUN_DIALOG_SHOW_NEW_INSET, "citation"));
722                         break;
723                 }
724
725                 case LFUN_CURSOR_FOLLOWS_SCROLLBAR_TOGGLE:
726                         LASSERT(lv, /**/);
727                         lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
728                         break;
729
730                 case LFUN_REPEAT: {
731                         // repeat command
732                         string countstr;
733                         string rest = split(argument, countstr, ' ');
734                         istringstream is(countstr);
735                         int count = 0;
736                         is >> count;
737                         //lyxerr << "repeat: count: " << count << " cmd: " << rest << endl;
738                         for (int i = 0; i < count; ++i)
739                                 dispatch(lyxaction.lookupFunc(rest));
740                         break;
741                 }
742
743                 case LFUN_COMMAND_SEQUENCE: {
744                         // argument contains ';'-terminated commands
745                         string arg = argument;
746                         if (theBufferList().isLoaded(buffer))
747                                 buffer->undo().beginUndoGroup();
748                         while (!arg.empty()) {
749                                 string first;
750                                 arg = split(arg, first, ';');
751                                 FuncRequest func(lyxaction.lookupFunc(first));
752                                 func.origin = cmd.origin;
753                                 dispatch(func);
754                         }
755                         if (theBufferList().isLoaded(buffer))
756                                 buffer->undo().endUndoGroup();
757                         break;
758                 }
759
760                 case LFUN_COMMAND_ALTERNATIVES: {
761                         // argument contains ';'-terminated commands
762                         string arg = argument;
763                         while (!arg.empty()) {
764                                 string first;
765                                 arg = split(arg, first, ';');
766                                 FuncRequest func(lyxaction.lookupFunc(first));
767                                 func.origin = cmd.origin;
768                                 FuncStatus stat = getStatus(func);
769                                 if (stat.enabled()) {
770                                         dispatch(func);
771                                         break;
772                                 }
773                         }
774                         break;
775                 }
776
777                 case LFUN_CALL: {
778                         FuncRequest func;
779                         if (theTopLevelCmdDef().lock(argument, func)) {
780                                 func.origin = cmd.origin;
781                                 dispatch(func);
782                                 theTopLevelCmdDef().release(argument);
783                         } else {
784                                 if (func.action == LFUN_UNKNOWN_ACTION) {
785                                         // unknown command definition
786                                         lyxerr << "Warning: unknown command definition `"
787                                                    << argument << "'"
788                                                    << endl;
789                                 } else {
790                                         // recursion detected
791                                         lyxerr << "Warning: Recursion in the command definition `"
792                                                    << argument << "' detected"
793                                                    << endl;
794                                 }
795                         }
796                         break;
797                 }
798
799                 case LFUN_PREFERENCES_SAVE: {
800                         lyxrc.write(makeAbsPath("preferences",
801                                                 package().user_support().absFilename()),
802                                     false);
803                         break;
804                 }
805
806                 case LFUN_BUFFER_SAVE_AS_DEFAULT: {
807                         string const fname =
808                                 addName(addPath(package().user_support().absFilename(), "templates/"),
809                                         "defaults.lyx");
810                         Buffer defaults(fname);
811
812                         istringstream ss(argument);
813                         Lexer lex;
814                         lex.setStream(ss);
815                         int const unknown_tokens = defaults.readHeader(lex);
816
817                         if (unknown_tokens != 0) {
818                                 lyxerr << "Warning in LFUN_BUFFER_SAVE_AS_DEFAULT!\n"
819                                        << unknown_tokens << " unknown token"
820                                        << (unknown_tokens == 1 ? "" : "s")
821                                        << endl;
822                         }
823
824                         if (defaults.writeFile(FileName(defaults.absFileName())))
825                                 setMessage(bformat(_("Document defaults saved in %1$s"),
826                                                    makeDisplayPath(fname)));
827                         else
828                                 setErrorMessage(from_ascii(N_("Unable to save document defaults")));
829                         break;
830                 }
831
832                 case LFUN_LYXRC_APPLY: {
833                         // reset active key sequences, since the bindings
834                         // are updated (bug 6064)
835                         keyseq.reset();
836                         LyXRC const lyxrc_orig = lyxrc;
837
838                         istringstream ss(argument);
839                         bool const success = lyxrc.read(ss) == 0;
840
841                         if (!success) {
842                                 lyxerr << "Warning in LFUN_LYXRC_APPLY!\n"
843                                        << "Unable to read lyxrc data"
844                                        << endl;
845                                 break;
846                         }
847
848                         actOnUpdatedPrefs(lyxrc_orig, lyxrc);
849
850                         setSpellChecker();
851
852                         theApp()->resetGui();
853
854                         /// We force the redraw in any case because there might be
855                         /// some screen font changes.
856                         /// FIXME: only the current view will be updated. the Gui
857                         /// class is able to furnish the list of views.
858                         updateFlags = Update::Force;
859                         break;
860                 }
861
862                 case LFUN_BOOKMARK_GOTO:
863                         // go to bookmark, open unopened file and switch to buffer if necessary
864                         gotoBookmark(convert<unsigned int>(to_utf8(cmd.argument())), true, true);
865                         updateFlags = Update::FitCursor;
866                         break;
867
868                 case LFUN_BOOKMARK_CLEAR:
869                         theSession().bookmarks().clear();
870                         break;
871
872                 default:
873                         LASSERT(theApp(), /**/);
874                         // Let the frontend dispatch its own actions.
875                         if (theApp()->dispatch(cmd))
876                                 // Nothing more to do.
877                                 return;
878
879                         // Everything below is only for active window
880                         if (lv == 0)
881                                 break;
882
883                         // Start an undo group. This may be needed for
884                         // some stuff like inset-apply on labels.
885                         if (theBufferList().isLoaded(buffer))
886                                 buffer->undo().beginUndoGroup();
887                                 
888                         // Let the current LyXView dispatch its own actions.
889                         if (lv->dispatch(cmd)) {
890                                 BufferView * bv = lv->currentBufferView();
891                                 if (bv) {
892                                         buffer = &(bv->buffer());
893                                         updateFlags = bv->cursor().result().update();
894                                         if (theBufferList().isLoaded(buffer))
895                                                 buffer->undo().endUndoGroup();
896                                 }
897                                 break;
898                         }
899
900                         BufferView * bv = lv->currentBufferView();
901                         LASSERT(bv, /**/);
902
903                         // Let the current BufferView dispatch its own actions.
904                         if (bv->dispatch(cmd)) {
905                                 // The BufferView took care of its own updates if needed.
906                                 buffer = &(bv->buffer());
907                                 updateFlags = Update::None;
908                                 if (theBufferList().isLoaded(buffer))
909                                         buffer->undo().endUndoGroup();
910                                 break;
911                         }
912
913                         BufferView * doc_bv = lv->documentBufferView();
914                         // Try with the document BufferView dispatch if any.
915                         if (doc_bv && doc_bv->dispatch(cmd)) {
916                                 // The BufferView took care of its own updates if needed.
917                                 buffer = &(doc_bv->buffer());
918                                 updateFlags = Update::None;
919                                 if (theBufferList().isLoaded(buffer))
920                                         buffer->undo().endUndoGroup();
921                                 break;
922                         }
923
924                         // OK, so try the current Buffer itself...
925                         DispatchResult dr;
926                         bv->buffer().dispatch(cmd, dr);
927                         if (dr.dispatched()) {
928                                 updateFlags = dr.update();
929                                 break;
930                         }
931                         // and with the document Buffer.
932                         if (doc_bv) {
933                                 doc_bv->buffer().dispatch(cmd, dr);
934                                 if (dr.dispatched()) {
935                                         updateFlags = dr.update();
936                                         break;
937                                 }
938                         }
939
940                         // Is this a function that acts on inset at point?
941                         Inset * inset = bv->cursor().nextInset();
942                         if (lyxaction.funcHasFlag(action, LyXAction::AtPoint)
943                             && inset) {
944                                 bv->cursor().result().dispatched(true);
945                                 bv->cursor().result().update(Update::FitCursor | Update::Force);
946                                 FuncRequest tmpcmd = cmd;
947                                 inset->dispatch(bv->cursor(), tmpcmd);
948                                 if (bv->cursor().result().dispatched()) {
949                                         updateFlags = bv->cursor().result().update();
950                                         break;
951                                 }
952                         }
953
954                         // Let the current Cursor dispatch its own actions.
955                         Cursor old = bv->cursor();
956                         bv->cursor().getPos(cursorPosBeforeDispatchX_,
957                                                 cursorPosBeforeDispatchY_);
958                         bv->cursor().dispatch(cmd);
959
960                         // notify insets we just left
961                         if (bv->cursor() != old) {
962                                 old.fixIfBroken();
963                                 bool badcursor = notifyCursorLeavesOrEnters(old, bv->cursor());
964                                 if (badcursor)
965                                         bv->cursor().fixIfBroken();
966                         }
967
968                         if (theBufferList().isLoaded(buffer))
969                                 buffer->undo().endUndoGroup();
970
971                         // update completion. We do it here and not in
972                         // processKeySym to avoid another redraw just for a
973                         // changed inline completion
974                         if (cmd.origin == FuncRequest::KEYBOARD) {
975                                 if (cmd.action == LFUN_SELF_INSERT
976                                     || (cmd.action == LFUN_ERT_INSERT && bv->cursor().inMathed()))
977                                         lv->updateCompletion(bv->cursor(), true, true);
978                                 else if (cmd.action == LFUN_CHAR_DELETE_BACKWARD)
979                                         lv->updateCompletion(bv->cursor(), false, true);
980                                 else
981                                         lv->updateCompletion(bv->cursor(), false, false);
982                         }
983
984                         updateFlags = bv->cursor().result().update();
985                 }
986
987                 // if we executed a mutating lfun, mark the buffer as dirty
988                 if (theBufferList().isLoaded(buffer) && flag.enabled()
989                     && !lyxaction.funcHasFlag(action, LyXAction::NoBuffer)
990                     && !lyxaction.funcHasFlag(action, LyXAction::ReadOnly))
991                         buffer->markDirty();                    
992
993                 if (lv && lv->currentBufferView()) {
994                         // BufferView::update() updates the ViewMetricsInfo and
995                         // also initializes the position cache for all insets in
996                         // (at least partially) visible top-level paragraphs.
997                         // We will redraw the screen only if needed.
998                         lv->currentBufferView()->processUpdateFlags(updateFlags);
999
1000                         // Do we have a selection?
1001                         theSelection().haveSelection(
1002                                 lv->currentBufferView()->cursor().selection());
1003                         
1004                         // update gui
1005                         lv->restartCursor();
1006                 }
1007         }
1008         if (lv) {
1009                 // Some messages may already be translated, so we cannot use _()
1010                 sendDispatchMessage(translateIfPossible(getMessage()), cmd);
1011         }
1012 }
1013
1014
1015 void LyXFunc::sendDispatchMessage(docstring const & msg, FuncRequest const & cmd)
1016 {
1017         const bool verbose = (cmd.origin == FuncRequest::MENU
1018                               || cmd.origin == FuncRequest::TOOLBAR
1019                               || cmd.origin == FuncRequest::COMMANDBUFFER);
1020
1021         LyXView * lv = theApp()->currentWindow();
1022         if (cmd.action == LFUN_SELF_INSERT || !verbose) {
1023                 LYXERR(Debug::ACTION, "dispatch msg is " << to_utf8(msg));
1024                 if (!msg.empty())
1025                         lv->message(msg);
1026                 return;
1027         }
1028
1029         docstring dispatch_msg = msg;
1030         if (!dispatch_msg.empty())
1031                 dispatch_msg += ' ';
1032
1033         docstring comname = from_utf8(lyxaction.getActionName(cmd.action));
1034
1035         bool argsadded = false;
1036
1037         if (!cmd.argument().empty()) {
1038                 if (cmd.action != LFUN_UNKNOWN_ACTION) {
1039                         comname += ' ' + cmd.argument();
1040                         argsadded = true;
1041                 }
1042         }
1043
1044         docstring const shortcuts = theTopLevelKeymap().printBindings(cmd, KeySequence::ForGui);
1045
1046         if (!shortcuts.empty())
1047                 comname += ": " + shortcuts;
1048         else if (!argsadded && !cmd.argument().empty())
1049                 comname += ' ' + cmd.argument();
1050
1051         if (!comname.empty()) {
1052                 comname = rtrim(comname);
1053                 dispatch_msg += '(' + rtrim(comname) + ')';
1054         }
1055
1056         LYXERR(Debug::ACTION, "verbose dispatch msg " << to_utf8(dispatch_msg));
1057         if (!dispatch_msg.empty())
1058                 lv->message(dispatch_msg);
1059 }
1060
1061
1062 // Each LyXView should have it's own message method. lyxview and
1063 // the minibuffer would use the minibuffer, but lyxserver would
1064 // send an ERROR signal to its client.  Alejandro 970603
1065 // This function is bit problematic when it comes to NLS, to make the
1066 // lyx servers client be language indepenent we must not translate
1067 // strings sent to this func.
1068 void LyXFunc::setErrorMessage(docstring const & m) const
1069 {
1070         dispatch_buffer = m;
1071         errorstat = true;
1072 }
1073
1074
1075 void LyXFunc::setMessage(docstring const & m) const
1076 {
1077         dispatch_buffer = m;
1078 }
1079
1080
1081 docstring LyXFunc::viewStatusMessage()
1082 {
1083         // When meta-fake key is pressed, show the key sequence so far + "M-".
1084         if (wasMetaKey())
1085                 return keyseq.print(KeySequence::ForGui) + "M-";
1086
1087         // Else, when a non-complete key sequence is pressed,
1088         // show the available options.
1089         if (keyseq.length() > 0 && !keyseq.deleted())
1090                 return keyseq.printOptions(true);
1091
1092         LyXView * lv = theApp()->currentWindow();
1093         LASSERT(lv, /**/);
1094         if (!lv->currentBufferView())
1095                 return _("Welcome to LyX!");
1096
1097         return lv->currentBufferView()->cursor().currentState();
1098 }
1099
1100
1101 bool LyXFunc::wasMetaKey() const
1102 {
1103         return (meta_fake_bit != NoModifier);
1104 }
1105
1106
1107 namespace {
1108
1109 void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
1110 {
1111         // Why the switch you might ask. It is a trick to ensure that all
1112         // the elements in the LyXRCTags enum is handled. As you can see
1113         // there are no breaks at all. So it is just a huge fall-through.
1114         // The nice thing is that we will get a warning from the compiler
1115         // if we forget an element.
1116         LyXRC::LyXRCTags tag = LyXRC::RC_LAST;
1117         switch (tag) {
1118         case LyXRC::RC_ACCEPT_COMPOUND:
1119         case LyXRC::RC_ALT_LANG:
1120         case LyXRC::RC_PLAINTEXT_LINELEN:
1121         case LyXRC::RC_PLAINTEXT_ROFF_COMMAND:
1122         case LyXRC::RC_AUTOCORRECTION_MATH:
1123         case LyXRC::RC_AUTOREGIONDELETE:
1124         case LyXRC::RC_AUTORESET_OPTIONS:
1125         case LyXRC::RC_AUTOSAVE:
1126         case LyXRC::RC_AUTO_NUMBER:
1127         case LyXRC::RC_BACKUPDIR_PATH:
1128         case LyXRC::RC_BIBTEX_ALTERNATIVES:
1129         case LyXRC::RC_BIBTEX_COMMAND:
1130         case LyXRC::RC_BINDFILE:
1131         case LyXRC::RC_CHECKLASTFILES:
1132         case LyXRC::RC_COMPLETION_CURSOR_TEXT:
1133         case LyXRC::RC_COMPLETION_INLINE_DELAY:
1134         case LyXRC::RC_COMPLETION_INLINE_DOTS:
1135         case LyXRC::RC_COMPLETION_INLINE_MATH:
1136         case LyXRC::RC_COMPLETION_INLINE_TEXT:
1137         case LyXRC::RC_COMPLETION_POPUP_AFTER_COMPLETE:
1138         case LyXRC::RC_COMPLETION_POPUP_DELAY:
1139         case LyXRC::RC_COMPLETION_POPUP_MATH:
1140         case LyXRC::RC_COMPLETION_POPUP_TEXT:
1141         case LyXRC::RC_USELASTFILEPOS:
1142         case LyXRC::RC_LOADSESSION:
1143         case LyXRC::RC_CHKTEX_COMMAND:
1144         case LyXRC::RC_CONVERTER:
1145         case LyXRC::RC_CONVERTER_CACHE_MAXAGE:
1146         case LyXRC::RC_COPIER:
1147         case LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR:
1148         case LyXRC::RC_SCROLL_BELOW_DOCUMENT:
1149         case LyXRC::RC_DATE_INSERT_FORMAT:
1150         case LyXRC::RC_DEFAULT_LANGUAGE:
1151         case LyXRC::RC_GUI_LANGUAGE:
1152         case LyXRC::RC_DEFAULT_PAPERSIZE:
1153         case LyXRC::RC_DEFAULT_VIEW_FORMAT:
1154         case LyXRC::RC_DEFFILE:
1155         case LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN:
1156         case LyXRC::RC_DISPLAY_GRAPHICS:
1157         case LyXRC::RC_DOCUMENTPATH:
1158                 if (lyxrc_orig.document_path != lyxrc_new.document_path) {
1159                         FileName path(lyxrc_new.document_path);
1160                         if (path.exists() && path.isDirectory())
1161                                 package().document_dir() = FileName(lyxrc.document_path);
1162                 }
1163         case LyXRC::RC_EDITOR_ALTERNATIVES:
1164         case LyXRC::RC_ESC_CHARS:
1165         case LyXRC::RC_EXAMPLEPATH:
1166         case LyXRC::RC_FONT_ENCODING:
1167         case LyXRC::RC_FORMAT:
1168         case LyXRC::RC_GROUP_LAYOUTS:
1169         case LyXRC::RC_HUNSPELLDIR_PATH:
1170         case LyXRC::RC_INDEX_ALTERNATIVES:
1171         case LyXRC::RC_INDEX_COMMAND:
1172         case LyXRC::RC_JBIBTEX_COMMAND:
1173         case LyXRC::RC_JINDEX_COMMAND:
1174         case LyXRC::RC_NOMENCL_COMMAND:
1175         case LyXRC::RC_INPUT:
1176         case LyXRC::RC_KBMAP:
1177         case LyXRC::RC_KBMAP_PRIMARY:
1178         case LyXRC::RC_KBMAP_SECONDARY:
1179         case LyXRC::RC_LABEL_INIT_LENGTH:
1180         case LyXRC::RC_LANGUAGE_AUTO_BEGIN:
1181         case LyXRC::RC_LANGUAGE_AUTO_END:
1182         case LyXRC::RC_LANGUAGE_COMMAND_BEGIN:
1183         case LyXRC::RC_LANGUAGE_COMMAND_END:
1184         case LyXRC::RC_LANGUAGE_COMMAND_LOCAL:
1185         case LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS:
1186         case LyXRC::RC_LANGUAGE_PACKAGE:
1187         case LyXRC::RC_LANGUAGE_USE_BABEL:
1188         case LyXRC::RC_MAC_LIKE_WORD_MOVEMENT:
1189         case LyXRC::RC_MACRO_EDIT_STYLE:
1190         case LyXRC::RC_MAKE_BACKUP:
1191         case LyXRC::RC_MARK_FOREIGN_LANGUAGE:
1192         case LyXRC::RC_MOUSE_WHEEL_SPEED:
1193         case LyXRC::RC_NUMLASTFILES:
1194         case LyXRC::RC_PARAGRAPH_MARKERS:
1195         case LyXRC::RC_PATH_PREFIX:
1196                 if (lyxrc_orig.path_prefix != lyxrc_new.path_prefix) {
1197                         prependEnvPath("PATH", lyxrc.path_prefix);
1198                 }
1199         case LyXRC::RC_PERS_DICT:
1200         case LyXRC::RC_PREVIEW:
1201         case LyXRC::RC_PREVIEW_HASHED_LABELS:
1202         case LyXRC::RC_PREVIEW_SCALE_FACTOR:
1203         case LyXRC::RC_PRINTCOLLCOPIESFLAG:
1204         case LyXRC::RC_PRINTCOPIESFLAG:
1205         case LyXRC::RC_PRINTER:
1206         case LyXRC::RC_PRINTEVENPAGEFLAG:
1207         case LyXRC::RC_PRINTEXSTRAOPTIONS:
1208         case LyXRC::RC_PRINTFILEEXTENSION:
1209         case LyXRC::RC_PRINTLANDSCAPEFLAG:
1210         case LyXRC::RC_PRINTODDPAGEFLAG:
1211         case LyXRC::RC_PRINTPAGERANGEFLAG:
1212         case LyXRC::RC_PRINTPAPERDIMENSIONFLAG:
1213         case LyXRC::RC_PRINTPAPERFLAG:
1214         case LyXRC::RC_PRINTREVERSEFLAG:
1215         case LyXRC::RC_PRINTSPOOL_COMMAND:
1216         case LyXRC::RC_PRINTSPOOL_PRINTERPREFIX:
1217         case LyXRC::RC_PRINTTOFILE:
1218         case LyXRC::RC_PRINTTOPRINTER:
1219         case LyXRC::RC_PRINT_ADAPTOUTPUT:
1220         case LyXRC::RC_PRINT_COMMAND:
1221         case LyXRC::RC_RTL_SUPPORT:
1222         case LyXRC::RC_SCREEN_DPI:
1223         case LyXRC::RC_SCREEN_FONT_ROMAN:
1224         case LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY:
1225         case LyXRC::RC_SCREEN_FONT_SANS:
1226         case LyXRC::RC_SCREEN_FONT_SANS_FOUNDRY:
1227         case LyXRC::RC_SCREEN_FONT_SCALABLE:
1228         case LyXRC::RC_SCREEN_FONT_SIZES:
1229         case LyXRC::RC_SCREEN_FONT_TYPEWRITER:
1230         case LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
1231         case LyXRC::RC_GEOMETRY_SESSION:
1232         case LyXRC::RC_SCREEN_ZOOM:
1233         case LyXRC::RC_SERVERPIPE:
1234         case LyXRC::RC_SET_COLOR:
1235         case LyXRC::RC_SHOW_BANNER:
1236         case LyXRC::RC_OPEN_BUFFERS_IN_TABS:
1237         case LyXRC::RC_SPELL_COMMAND:
1238         case LyXRC::RC_SPELLCHECKER:
1239         case LyXRC::RC_SPELLCHECK_CONTINUOUSLY:
1240         case LyXRC::RC_SPLITINDEX_COMMAND:
1241         case LyXRC::RC_TEMPDIRPATH:
1242         case LyXRC::RC_TEMPLATEPATH:
1243         case LyXRC::RC_TEX_ALLOWS_SPACES:
1244         case LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS:
1245                 if (lyxrc_orig.windows_style_tex_paths != lyxrc_new.windows_style_tex_paths) {
1246                         os::windows_style_tex_paths(lyxrc_new.windows_style_tex_paths);
1247                 }
1248         case LyXRC::RC_THESAURUSDIRPATH:
1249         case LyXRC::RC_UIFILE:
1250         case LyXRC::RC_USER_EMAIL:
1251         case LyXRC::RC_USER_NAME:
1252         case LyXRC::RC_USETEMPDIR:
1253         case LyXRC::RC_USE_ALT_LANG:
1254         case LyXRC::RC_USE_CONVERTER_CACHE:
1255         case LyXRC::RC_USE_ESC_CHARS:
1256         case LyXRC::RC_USE_INP_ENC:
1257         case LyXRC::RC_USE_PERS_DICT:
1258         case LyXRC::RC_USE_TOOLTIP:
1259         case LyXRC::RC_USE_PIXMAP_CACHE:
1260         case LyXRC::RC_USE_SPELL_LIB:
1261         case LyXRC::RC_VIEWDVI_PAPEROPTION:
1262         case LyXRC::RC_SORT_LAYOUTS:
1263         case LyXRC::RC_FULL_SCREEN_LIMIT:
1264         case LyXRC::RC_FULL_SCREEN_SCROLLBAR:
1265         case LyXRC::RC_FULL_SCREEN_MENUBAR:
1266         case LyXRC::RC_FULL_SCREEN_TABBAR:
1267         case LyXRC::RC_FULL_SCREEN_TOOLBARS:
1268         case LyXRC::RC_FULL_SCREEN_WIDTH:
1269         case LyXRC::RC_VISUAL_CURSOR:
1270         case LyXRC::RC_VIEWER:
1271         case LyXRC::RC_VIEWER_ALTERNATIVES:
1272         case LyXRC::RC_LAST:
1273                 break;
1274         }
1275 }
1276
1277 } // namespace anon
1278 } // namespace lyx