]> git.lyx.org Git - lyx.git/blob - src/LyXFunc.cpp
Transfer special getStatus() code from LyXFunc to BufferView, GuiView and GuiApplication.
[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_SERVER_GOTO_FILE_ROW:
462         case LFUN_CURSOR_FOLLOWS_SCROLLBAR_TOGGLE:
463         case LFUN_REPEAT:
464         case LFUN_PREFERENCES_SAVE:
465         case LFUN_INSET_EDIT:
466         case LFUN_BUFFER_SAVE_AS_DEFAULT:
467         case LFUN_LYXRC_APPLY:
468                 // these are handled in our dispatch()
469                 break;
470
471         default:
472                 if (!theApp()) {
473                         enable = false;
474                         break;
475                 }
476                 if (theApp()->getStatus(cmd, flag))
477                         break;
478
479                 // Does the view know something?
480                 LyXView * lv = theApp()->currentWindow();
481                 if (!lv) {
482                         enable = false;
483                         break;
484                 }
485                 if (lv->getStatus(cmd, flag))
486                         break;
487
488                 BufferView * bv = lv->currentBufferView();
489                 BufferView * doc_bv = lv->documentBufferView();
490                 // If we do not have a BufferView, then other functions are disabled
491                 if (!bv) {
492                         enable = false;
493                         break;
494                 }
495                 // try the BufferView
496                 bool decided = bv->getStatus(cmd, flag);
497                 if (!decided)
498                         // try the Buffer
499                         decided = bv->buffer().getStatus(cmd, flag);
500                 if (!decided && doc_bv)
501                         // try the Document Buffer
502                         decided = doc_bv->buffer().getStatus(cmd, flag);
503         }
504
505         if (!enable)
506                 flag.setEnabled(false);
507
508         // the default error message if we disable the command
509         if (!flag.enabled() && flag.message().empty())
510                 flag.message(from_utf8(N_("Command disabled")));
511
512         return flag;
513 }
514
515
516 namespace {
517
518 void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new);
519
520 } //namespace anon
521
522
523 void LyXFunc::dispatch(FuncRequest const & cmd)
524 {
525         string const argument = to_utf8(cmd.argument());
526         FuncCode const action = cmd.action;
527
528         LYXERR(Debug::ACTION, "\nLyXFunc::dispatch: cmd: " << cmd);
529         //lyxerr << "LyXFunc::dispatch: cmd: " << cmd << endl;
530
531         // we have not done anything wrong yet.
532         errorstat = false;
533         dispatch_buffer.erase();
534
535         // redraw the screen at the end (first of the two drawing steps).
536         //This is done unless explicitely requested otherwise
537         Update::flags updateFlags = Update::FitCursor;
538
539         LyXView * lv = theApp()->currentWindow();
540
541         FuncStatus const flag = getStatus(cmd);
542         if (!flag.enabled()) {
543                 // We cannot use this function here
544                 LYXERR(Debug::ACTION, "LyXFunc::dispatch: "
545                        << lyxaction.getActionName(action)
546                        << " [" << action << "] is disabled at this location");
547                 setErrorMessage(flag.message());
548                 if (lv)
549                         lv->restartCursor();
550         } else {
551                 Buffer * buffer = 0;
552                 if (lv && lv->currentBufferView())
553                         buffer = &lv->currentBufferView()->buffer();
554                 switch (action) {
555
556                 case LFUN_COMMAND_PREFIX:
557                         LASSERT(lv, /**/);
558                         lv->message(keyseq.printOptions(true));
559                         break;
560
561                 case LFUN_CANCEL:
562                         LASSERT(lv && lv->currentBufferView(), /**/);
563                         keyseq.reset();
564                         meta_fake_bit = NoModifier;
565                         if (buffer)
566                                 // cancel any selection
567                                 dispatch(FuncRequest(LFUN_MARK_OFF));
568                         setMessage(from_ascii(N_("Cancel")));
569                         break;
570
571                 case LFUN_META_PREFIX:
572                         meta_fake_bit = AltModifier;
573                         setMessage(keyseq.print(KeySequence::ForGui));
574                         break;
575
576                 // --- Menus -----------------------------------------------
577                 case LFUN_RECONFIGURE:
578                         // argument is any additional parameter to the configure.py command
579                         reconfigure(lv, argument);
580                         break;
581
582                 // --- lyxserver commands ----------------------------
583                 case LFUN_SERVER_GET_FILENAME:
584                         LASSERT(lv && buffer, /**/);
585                         setMessage(from_utf8(buffer->absFileName()));
586                         LYXERR(Debug::INFO, "FNAME["
587                                 << buffer->absFileName() << ']');
588                         break;
589
590                 case LFUN_SERVER_NOTIFY:
591                         dispatch_buffer = keyseq.print(KeySequence::Portable);
592                         theServer().notifyClient(to_utf8(dispatch_buffer));
593                         break;
594
595                 case LFUN_SERVER_GOTO_FILE_ROW: {
596                         LASSERT(lv, /**/);
597                         string file_name;
598                         int row;
599                         istringstream is(argument);
600                         is >> file_name >> row;
601                         file_name = os::internal_path(file_name);
602                         Buffer * buf = 0;
603                         bool loaded = false;
604                         string const abstmp = package().temp_dir().absFilename();
605                         string const realtmp = package().temp_dir().realPath();
606                         // We have to use os::path_prefix_is() here, instead of
607                         // simply prefixIs(), because the file name comes from
608                         // an external application and may need case adjustment.
609                         if (os::path_prefix_is(file_name, abstmp, os::CASE_ADJUSTED)
610                             || os::path_prefix_is(file_name, realtmp, os::CASE_ADJUSTED)) {
611                                 // Needed by inverse dvi search. If it is a file
612                                 // in tmpdir, call the apropriated function.
613                                 // If tmpdir is a symlink, we may have the real
614                                 // path passed back, so we correct for that.
615                                 if (!prefixIs(file_name, abstmp))
616                                         file_name = subst(file_name, realtmp, abstmp);
617                                 buf = theBufferList().getBufferFromTmp(file_name);
618                         } else {
619                                 // Must replace extension of the file to be .lyx
620                                 // and get full path
621                                 FileName const s = fileSearch(string(), changeExtension(file_name, ".lyx"), "lyx");
622                                 // Either change buffer or load the file
623                                 if (theBufferList().exists(s))
624                                         buf = theBufferList().getBuffer(s);
625                                 else if (s.exists()) {
626                                         buf = lv->loadDocument(s);
627                                         loaded = true;
628                                 } else
629                                         lv->message(bformat(
630                                                 _("File does not exist: %1$s"),
631                                                 makeDisplayPath(file_name)));
632                         }
633
634                         if (!buf) {
635                                 updateFlags = Update::None;
636                                 break;
637                         }
638
639                         buf->updateLabels();
640                         lv->setBuffer(buf);
641                         lv->documentBufferView()->setCursorFromRow(row);
642                         if (loaded)
643                                 buf->errors("Parse");
644                         updateFlags = Update::FitCursor;
645                         break;
646                 }
647
648
649                 case LFUN_DIALOG_SHOW_NEW_INSET: {
650                         LASSERT(lv, /**/);
651                         string const name = cmd.getArg(0);
652                         InsetCode code = insetCode(name);
653                         string data = trim(to_utf8(cmd.argument()).substr(name.size()));
654                         bool insetCodeOK = true;
655                         switch (code) {
656                         case BIBITEM_CODE:
657                         case BIBTEX_CODE:
658                         case INDEX_CODE:
659                         case LABEL_CODE:
660                         case NOMENCL_CODE:
661                         case NOMENCL_PRINT_CODE:
662                         case REF_CODE:
663                         case TOC_CODE:
664                         case HYPERLINK_CODE: {
665                                 InsetCommandParams p(code);
666                                 data = InsetCommand::params2string(name, p);
667                                 break;
668                         }
669                         case INCLUDE_CODE: {
670                                 // data is the include type: one of "include",
671                                 // "input", "verbatiminput" or "verbatiminput*"
672                                 if (data.empty())
673                                         // default type is requested
674                                         data = "include";
675                                 InsetCommandParams p(INCLUDE_CODE, data);
676                                 data = InsetCommand::params2string("include", p);
677                                 break;
678                         }
679                         case BOX_CODE: {
680                                 // \c data == "Boxed" || "Frameless" etc
681                                 InsetBoxParams p(data);
682                                 data = InsetBox::params2string(p);
683                                 break;
684                         }
685                         case BRANCH_CODE: {
686                                 InsetBranchParams p;
687                                 data = InsetBranch::params2string(p);
688                                 break;
689                         }
690                         case CITE_CODE: {
691                                 InsetCommandParams p(CITE_CODE);
692                                 data = InsetCommand::params2string(name, p);
693                                 break;
694                         }
695                         case ERT_CODE: {
696                                 data = InsetERT::params2string(InsetCollapsable::Open);
697                                 break;
698                         }
699                         case EXTERNAL_CODE: {
700                                 InsetExternalParams p;
701                                 data = InsetExternal::params2string(p, *buffer);
702                                 break;
703                         }
704                         case FLOAT_CODE:  {
705                                 InsetFloatParams p;
706                                 data = InsetFloat::params2string(p);
707                                 break;
708                         }
709                         case LISTINGS_CODE: {
710                                 InsetListingsParams p;
711                                 data = InsetListings::params2string(p);
712                                 break;
713                         }
714                         case GRAPHICS_CODE: {
715                                 InsetGraphicsParams p;
716                                 data = InsetGraphics::params2string(p, *buffer);
717                                 break;
718                         }
719                         case NOTE_CODE: {
720                                 InsetNoteParams p;
721                                 data = InsetNote::params2string(p);
722                                 break;
723                         }
724                         case PHANTOM_CODE: {
725                                 InsetPhantomParams p;
726                                 data = InsetPhantom::params2string(p);
727                                 break;
728                         }
729                         case SPACE_CODE: {
730                                 InsetSpaceParams p;
731                                 data = InsetSpace::params2string(p);
732                                 break;
733                         }
734                         case VSPACE_CODE: {
735                                 VSpace space;
736                                 data = InsetVSpace::params2string(space);
737                                 break;
738                         }
739                         case WRAP_CODE: {
740                                 InsetWrapParams p;
741                                 data = InsetWrap::params2string(p);
742                                 break;
743                         }
744                         default:
745                                 lyxerr << "Inset type '" << name << 
746                                         "' not recognized in LFUN_DIALOG_SHOW_NEW_INSET" <<  endl;
747                                 insetCodeOK = false;
748                                 break;
749                         } // end switch(code)
750                         if (insetCodeOK)
751                                 dispatch(FuncRequest(LFUN_DIALOG_SHOW, name + " " + data));
752                         break;
753                 }
754
755                 case LFUN_CITATION_INSERT: {
756                         LASSERT(lv, /**/);
757                         if (!argument.empty()) {
758                                 // we can have one optional argument, delimited by '|'
759                                 // citation-insert <key>|<text_before>
760                                 // this should be enhanced to also support text_after
761                                 // and citation style
762                                 string arg = argument;
763                                 string opt1;
764                                 if (contains(argument, "|")) {
765                                         arg = token(argument, '|', 0);
766                                         opt1 = token(argument, '|', 1);
767                                 }
768                                 InsetCommandParams icp(CITE_CODE);
769                                 icp["key"] = from_utf8(arg);
770                                 if (!opt1.empty())
771                                         icp["before"] = from_utf8(opt1);
772                                 string icstr = InsetCommand::params2string("citation", icp);
773                                 FuncRequest fr(LFUN_INSET_INSERT, icstr);
774                                 dispatch(fr);
775                         } else
776                                 dispatch(FuncRequest(LFUN_DIALOG_SHOW_NEW_INSET, "citation"));
777                         break;
778                 }
779
780                 case LFUN_CURSOR_FOLLOWS_SCROLLBAR_TOGGLE:
781                         LASSERT(lv, /**/);
782                         lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
783                         break;
784
785                 case LFUN_REPEAT: {
786                         // repeat command
787                         string countstr;
788                         string rest = split(argument, countstr, ' ');
789                         istringstream is(countstr);
790                         int count = 0;
791                         is >> count;
792                         //lyxerr << "repeat: count: " << count << " cmd: " << rest << endl;
793                         for (int i = 0; i < count; ++i)
794                                 dispatch(lyxaction.lookupFunc(rest));
795                         break;
796                 }
797
798                 case LFUN_COMMAND_SEQUENCE: {
799                         // argument contains ';'-terminated commands
800                         string arg = argument;
801                         if (theBufferList().isLoaded(buffer))
802                                 buffer->undo().beginUndoGroup();
803                         while (!arg.empty()) {
804                                 string first;
805                                 arg = split(arg, first, ';');
806                                 FuncRequest func(lyxaction.lookupFunc(first));
807                                 func.origin = cmd.origin;
808                                 dispatch(func);
809                         }
810                         if (theBufferList().isLoaded(buffer))
811                                 buffer->undo().endUndoGroup();
812                         break;
813                 }
814
815                 case LFUN_COMMAND_ALTERNATIVES: {
816                         // argument contains ';'-terminated commands
817                         string arg = argument;
818                         while (!arg.empty()) {
819                                 string first;
820                                 arg = split(arg, first, ';');
821                                 FuncRequest func(lyxaction.lookupFunc(first));
822                                 func.origin = cmd.origin;
823                                 FuncStatus stat = getStatus(func);
824                                 if (stat.enabled()) {
825                                         dispatch(func);
826                                         break;
827                                 }
828                         }
829                         break;
830                 }
831
832                 case LFUN_CALL: {
833                         FuncRequest func;
834                         if (theTopLevelCmdDef().lock(argument, func)) {
835                                 func.origin = cmd.origin;
836                                 dispatch(func);
837                                 theTopLevelCmdDef().release(argument);
838                         } else {
839                                 if (func.action == LFUN_UNKNOWN_ACTION) {
840                                         // unknown command definition
841                                         lyxerr << "Warning: unknown command definition `"
842                                                    << argument << "'"
843                                                    << endl;
844                                 } else {
845                                         // recursion detected
846                                         lyxerr << "Warning: Recursion in the command definition `"
847                                                    << argument << "' detected"
848                                                    << endl;
849                                 }
850                         }
851                         break;
852                 }
853
854                 case LFUN_PREFERENCES_SAVE: {
855                         lyxrc.write(makeAbsPath("preferences",
856                                                 package().user_support().absFilename()),
857                                     false);
858                         break;
859                 }
860
861                 case LFUN_BUFFER_SAVE_AS_DEFAULT: {
862                         string const fname =
863                                 addName(addPath(package().user_support().absFilename(), "templates/"),
864                                         "defaults.lyx");
865                         Buffer defaults(fname);
866
867                         istringstream ss(argument);
868                         Lexer lex;
869                         lex.setStream(ss);
870                         int const unknown_tokens = defaults.readHeader(lex);
871
872                         if (unknown_tokens != 0) {
873                                 lyxerr << "Warning in LFUN_BUFFER_SAVE_AS_DEFAULT!\n"
874                                        << unknown_tokens << " unknown token"
875                                        << (unknown_tokens == 1 ? "" : "s")
876                                        << endl;
877                         }
878
879                         if (defaults.writeFile(FileName(defaults.absFileName())))
880                                 setMessage(bformat(_("Document defaults saved in %1$s"),
881                                                    makeDisplayPath(fname)));
882                         else
883                                 setErrorMessage(from_ascii(N_("Unable to save document defaults")));
884                         break;
885                 }
886
887                 case LFUN_LYXRC_APPLY: {
888                         // reset active key sequences, since the bindings
889                         // are updated (bug 6064)
890                         keyseq.reset();
891                         LyXRC const lyxrc_orig = lyxrc;
892
893                         istringstream ss(argument);
894                         bool const success = lyxrc.read(ss) == 0;
895
896                         if (!success) {
897                                 lyxerr << "Warning in LFUN_LYXRC_APPLY!\n"
898                                        << "Unable to read lyxrc data"
899                                        << endl;
900                                 break;
901                         }
902
903                         actOnUpdatedPrefs(lyxrc_orig, lyxrc);
904
905                         setSpellChecker();
906
907                         theApp()->resetGui();
908
909                         /// We force the redraw in any case because there might be
910                         /// some screen font changes.
911                         /// FIXME: only the current view will be updated. the Gui
912                         /// class is able to furnish the list of views.
913                         updateFlags = Update::Force;
914                         break;
915                 }
916
917                 case LFUN_BOOKMARK_GOTO:
918                         // go to bookmark, open unopened file and switch to buffer if necessary
919                         gotoBookmark(convert<unsigned int>(to_utf8(cmd.argument())), true, true);
920                         updateFlags = Update::FitCursor;
921                         break;
922
923                 case LFUN_BOOKMARK_CLEAR:
924                         theSession().bookmarks().clear();
925                         break;
926
927                 default:
928                         LASSERT(theApp(), /**/);
929                         // Let the frontend dispatch its own actions.
930                         if (theApp()->dispatch(cmd))
931                                 // Nothing more to do.
932                                 return;
933
934                         // Everything below is only for active window
935                         if (lv == 0)
936                                 break;
937
938                         // Start an undo group. This may be needed for
939                         // some stuff like inset-apply on labels.
940                         if (theBufferList().isLoaded(buffer))
941                                 buffer->undo().beginUndoGroup();
942                                 
943                         // Let the current LyXView dispatch its own actions.
944                         if (lv->dispatch(cmd)) {
945                                 BufferView * bv = lv->currentBufferView();
946                                 if (bv) {
947                                         buffer = &(bv->buffer());
948                                         updateFlags = bv->cursor().result().update();
949                                         if (theBufferList().isLoaded(buffer))
950                                                 buffer->undo().endUndoGroup();
951                                 }
952                                 break;
953                         }
954
955                         BufferView * bv = lv->currentBufferView();
956                         LASSERT(bv, /**/);
957
958                         // Let the current BufferView dispatch its own actions.
959                         if (bv->dispatch(cmd)) {
960                                 // The BufferView took care of its own updates if needed.
961                                 buffer = &(bv->buffer());
962                                 updateFlags = Update::None;
963                                 if (theBufferList().isLoaded(buffer))
964                                         buffer->undo().endUndoGroup();
965                                 break;
966                         }
967
968                         BufferView * doc_bv = lv->documentBufferView();
969                         // Try with the document BufferView dispatch if any.
970                         if (doc_bv && doc_bv->dispatch(cmd)) {
971                                 // The BufferView took care of its own updates if needed.
972                                 buffer = &(doc_bv->buffer());
973                                 updateFlags = Update::None;
974                                 if (theBufferList().isLoaded(buffer))
975                                         buffer->undo().endUndoGroup();
976                                 break;
977                         }
978
979                         // OK, so try the current Buffer itself...
980                         DispatchResult dr;
981                         bv->buffer().dispatch(cmd, dr);
982                         if (dr.dispatched()) {
983                                 updateFlags = dr.update();
984                                 break;
985                         }
986                         // and with the document Buffer.
987                         if (doc_bv) {
988                                 doc_bv->buffer().dispatch(cmd, dr);
989                                 if (dr.dispatched()) {
990                                         updateFlags = dr.update();
991                                         break;
992                                 }
993                         }
994
995                         // Is this a function that acts on inset at point?
996                         Inset * inset = bv->cursor().nextInset();
997                         if (lyxaction.funcHasFlag(action, LyXAction::AtPoint)
998                             && inset) {
999                                 bv->cursor().result().dispatched(true);
1000                                 bv->cursor().result().update(Update::FitCursor | Update::Force);
1001                                 FuncRequest tmpcmd = cmd;
1002                                 inset->dispatch(bv->cursor(), tmpcmd);
1003                                 if (bv->cursor().result().dispatched()) {
1004                                         updateFlags = bv->cursor().result().update();
1005                                         break;
1006                                 }
1007                         }
1008
1009                         // Let the current Cursor dispatch its own actions.
1010                         Cursor old = bv->cursor();
1011                         bv->cursor().getPos(cursorPosBeforeDispatchX_,
1012                                                 cursorPosBeforeDispatchY_);
1013                         bv->cursor().dispatch(cmd);
1014
1015                         // notify insets we just left
1016                         if (bv->cursor() != old) {
1017                                 old.fixIfBroken();
1018                                 bool badcursor = notifyCursorLeavesOrEnters(old, bv->cursor());
1019                                 if (badcursor)
1020                                         bv->cursor().fixIfBroken();
1021                         }
1022
1023                         if (theBufferList().isLoaded(buffer))
1024                                 buffer->undo().endUndoGroup();
1025
1026                         // update completion. We do it here and not in
1027                         // processKeySym to avoid another redraw just for a
1028                         // changed inline completion
1029                         if (cmd.origin == FuncRequest::KEYBOARD) {
1030                                 if (cmd.action == LFUN_SELF_INSERT
1031                                     || (cmd.action == LFUN_ERT_INSERT && bv->cursor().inMathed()))
1032                                         lv->updateCompletion(bv->cursor(), true, true);
1033                                 else if (cmd.action == LFUN_CHAR_DELETE_BACKWARD)
1034                                         lv->updateCompletion(bv->cursor(), false, true);
1035                                 else
1036                                         lv->updateCompletion(bv->cursor(), false, false);
1037                         }
1038
1039                         updateFlags = bv->cursor().result().update();
1040                 }
1041
1042                 // if we executed a mutating lfun, mark the buffer as dirty
1043                 if (theBufferList().isLoaded(buffer) && flag.enabled()
1044                     && !lyxaction.funcHasFlag(action, LyXAction::NoBuffer)
1045                     && !lyxaction.funcHasFlag(action, LyXAction::ReadOnly))
1046                         buffer->markDirty();                    
1047
1048                 if (lv && lv->currentBufferView()) {
1049                         // BufferView::update() updates the ViewMetricsInfo and
1050                         // also initializes the position cache for all insets in
1051                         // (at least partially) visible top-level paragraphs.
1052                         // We will redraw the screen only if needed.
1053                         lv->currentBufferView()->processUpdateFlags(updateFlags);
1054
1055                         // Do we have a selection?
1056                         theSelection().haveSelection(
1057                                 lv->currentBufferView()->cursor().selection());
1058                         
1059                         // update gui
1060                         lv->restartCursor();
1061                 }
1062         }
1063         if (lv) {
1064                 // Some messages may already be translated, so we cannot use _()
1065                 sendDispatchMessage(translateIfPossible(getMessage()), cmd);
1066         }
1067 }
1068
1069
1070 void LyXFunc::sendDispatchMessage(docstring const & msg, FuncRequest const & cmd)
1071 {
1072         const bool verbose = (cmd.origin == FuncRequest::MENU
1073                               || cmd.origin == FuncRequest::TOOLBAR
1074                               || cmd.origin == FuncRequest::COMMANDBUFFER);
1075
1076         LyXView * lv = theApp()->currentWindow();
1077         if (cmd.action == LFUN_SELF_INSERT || !verbose) {
1078                 LYXERR(Debug::ACTION, "dispatch msg is " << to_utf8(msg));
1079                 if (!msg.empty())
1080                         lv->message(msg);
1081                 return;
1082         }
1083
1084         docstring dispatch_msg = msg;
1085         if (!dispatch_msg.empty())
1086                 dispatch_msg += ' ';
1087
1088         docstring comname = from_utf8(lyxaction.getActionName(cmd.action));
1089
1090         bool argsadded = false;
1091
1092         if (!cmd.argument().empty()) {
1093                 if (cmd.action != LFUN_UNKNOWN_ACTION) {
1094                         comname += ' ' + cmd.argument();
1095                         argsadded = true;
1096                 }
1097         }
1098
1099         docstring const shortcuts = theTopLevelKeymap().printBindings(cmd, KeySequence::ForGui);
1100
1101         if (!shortcuts.empty())
1102                 comname += ": " + shortcuts;
1103         else if (!argsadded && !cmd.argument().empty())
1104                 comname += ' ' + cmd.argument();
1105
1106         if (!comname.empty()) {
1107                 comname = rtrim(comname);
1108                 dispatch_msg += '(' + rtrim(comname) + ')';
1109         }
1110
1111         LYXERR(Debug::ACTION, "verbose dispatch msg " << to_utf8(dispatch_msg));
1112         if (!dispatch_msg.empty())
1113                 lv->message(dispatch_msg);
1114 }
1115
1116
1117 // Each LyXView should have it's own message method. lyxview and
1118 // the minibuffer would use the minibuffer, but lyxserver would
1119 // send an ERROR signal to its client.  Alejandro 970603
1120 // This function is bit problematic when it comes to NLS, to make the
1121 // lyx servers client be language indepenent we must not translate
1122 // strings sent to this func.
1123 void LyXFunc::setErrorMessage(docstring const & m) const
1124 {
1125         dispatch_buffer = m;
1126         errorstat = true;
1127 }
1128
1129
1130 void LyXFunc::setMessage(docstring const & m) const
1131 {
1132         dispatch_buffer = m;
1133 }
1134
1135
1136 docstring LyXFunc::viewStatusMessage()
1137 {
1138         // When meta-fake key is pressed, show the key sequence so far + "M-".
1139         if (wasMetaKey())
1140                 return keyseq.print(KeySequence::ForGui) + "M-";
1141
1142         // Else, when a non-complete key sequence is pressed,
1143         // show the available options.
1144         if (keyseq.length() > 0 && !keyseq.deleted())
1145                 return keyseq.printOptions(true);
1146
1147         LyXView * lv = theApp()->currentWindow();
1148         LASSERT(lv, /**/);
1149         if (!lv->currentBufferView())
1150                 return _("Welcome to LyX!");
1151
1152         return lv->currentBufferView()->cursor().currentState();
1153 }
1154
1155
1156 bool LyXFunc::wasMetaKey() const
1157 {
1158         return (meta_fake_bit != NoModifier);
1159 }
1160
1161
1162 namespace {
1163
1164 void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
1165 {
1166         // Why the switch you might ask. It is a trick to ensure that all
1167         // the elements in the LyXRCTags enum is handled. As you can see
1168         // there are no breaks at all. So it is just a huge fall-through.
1169         // The nice thing is that we will get a warning from the compiler
1170         // if we forget an element.
1171         LyXRC::LyXRCTags tag = LyXRC::RC_LAST;
1172         switch (tag) {
1173         case LyXRC::RC_ACCEPT_COMPOUND:
1174         case LyXRC::RC_ALT_LANG:
1175         case LyXRC::RC_PLAINTEXT_LINELEN:
1176         case LyXRC::RC_PLAINTEXT_ROFF_COMMAND:
1177         case LyXRC::RC_AUTOCORRECTION_MATH:
1178         case LyXRC::RC_AUTOREGIONDELETE:
1179         case LyXRC::RC_AUTORESET_OPTIONS:
1180         case LyXRC::RC_AUTOSAVE:
1181         case LyXRC::RC_AUTO_NUMBER:
1182         case LyXRC::RC_BACKUPDIR_PATH:
1183         case LyXRC::RC_BIBTEX_ALTERNATIVES:
1184         case LyXRC::RC_BIBTEX_COMMAND:
1185         case LyXRC::RC_BINDFILE:
1186         case LyXRC::RC_CHECKLASTFILES:
1187         case LyXRC::RC_COMPLETION_CURSOR_TEXT:
1188         case LyXRC::RC_COMPLETION_INLINE_DELAY:
1189         case LyXRC::RC_COMPLETION_INLINE_DOTS:
1190         case LyXRC::RC_COMPLETION_INLINE_MATH:
1191         case LyXRC::RC_COMPLETION_INLINE_TEXT:
1192         case LyXRC::RC_COMPLETION_POPUP_AFTER_COMPLETE:
1193         case LyXRC::RC_COMPLETION_POPUP_DELAY:
1194         case LyXRC::RC_COMPLETION_POPUP_MATH:
1195         case LyXRC::RC_COMPLETION_POPUP_TEXT:
1196         case LyXRC::RC_USELASTFILEPOS:
1197         case LyXRC::RC_LOADSESSION:
1198         case LyXRC::RC_CHKTEX_COMMAND:
1199         case LyXRC::RC_CONVERTER:
1200         case LyXRC::RC_CONVERTER_CACHE_MAXAGE:
1201         case LyXRC::RC_COPIER:
1202         case LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR:
1203         case LyXRC::RC_SCROLL_BELOW_DOCUMENT:
1204         case LyXRC::RC_DATE_INSERT_FORMAT:
1205         case LyXRC::RC_DEFAULT_LANGUAGE:
1206         case LyXRC::RC_GUI_LANGUAGE:
1207         case LyXRC::RC_DEFAULT_PAPERSIZE:
1208         case LyXRC::RC_DEFAULT_VIEW_FORMAT:
1209         case LyXRC::RC_DEFFILE:
1210         case LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN:
1211         case LyXRC::RC_DISPLAY_GRAPHICS:
1212         case LyXRC::RC_DOCUMENTPATH:
1213                 if (lyxrc_orig.document_path != lyxrc_new.document_path) {
1214                         FileName path(lyxrc_new.document_path);
1215                         if (path.exists() && path.isDirectory())
1216                                 package().document_dir() = FileName(lyxrc.document_path);
1217                 }
1218         case LyXRC::RC_EDITOR_ALTERNATIVES:
1219         case LyXRC::RC_ESC_CHARS:
1220         case LyXRC::RC_EXAMPLEPATH:
1221         case LyXRC::RC_FONT_ENCODING:
1222         case LyXRC::RC_FORMAT:
1223         case LyXRC::RC_GROUP_LAYOUTS:
1224         case LyXRC::RC_HUNSPELLDIR_PATH:
1225         case LyXRC::RC_INDEX_ALTERNATIVES:
1226         case LyXRC::RC_INDEX_COMMAND:
1227         case LyXRC::RC_JBIBTEX_COMMAND:
1228         case LyXRC::RC_JINDEX_COMMAND:
1229         case LyXRC::RC_NOMENCL_COMMAND:
1230         case LyXRC::RC_INPUT:
1231         case LyXRC::RC_KBMAP:
1232         case LyXRC::RC_KBMAP_PRIMARY:
1233         case LyXRC::RC_KBMAP_SECONDARY:
1234         case LyXRC::RC_LABEL_INIT_LENGTH:
1235         case LyXRC::RC_LANGUAGE_AUTO_BEGIN:
1236         case LyXRC::RC_LANGUAGE_AUTO_END:
1237         case LyXRC::RC_LANGUAGE_COMMAND_BEGIN:
1238         case LyXRC::RC_LANGUAGE_COMMAND_END:
1239         case LyXRC::RC_LANGUAGE_COMMAND_LOCAL:
1240         case LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS:
1241         case LyXRC::RC_LANGUAGE_PACKAGE:
1242         case LyXRC::RC_LANGUAGE_USE_BABEL:
1243         case LyXRC::RC_MAC_LIKE_WORD_MOVEMENT:
1244         case LyXRC::RC_MACRO_EDIT_STYLE:
1245         case LyXRC::RC_MAKE_BACKUP:
1246         case LyXRC::RC_MARK_FOREIGN_LANGUAGE:
1247         case LyXRC::RC_MOUSE_WHEEL_SPEED:
1248         case LyXRC::RC_NUMLASTFILES:
1249         case LyXRC::RC_PARAGRAPH_MARKERS:
1250         case LyXRC::RC_PATH_PREFIX:
1251                 if (lyxrc_orig.path_prefix != lyxrc_new.path_prefix) {
1252                         prependEnvPath("PATH", lyxrc.path_prefix);
1253                 }
1254         case LyXRC::RC_PERS_DICT:
1255         case LyXRC::RC_PREVIEW:
1256         case LyXRC::RC_PREVIEW_HASHED_LABELS:
1257         case LyXRC::RC_PREVIEW_SCALE_FACTOR:
1258         case LyXRC::RC_PRINTCOLLCOPIESFLAG:
1259         case LyXRC::RC_PRINTCOPIESFLAG:
1260         case LyXRC::RC_PRINTER:
1261         case LyXRC::RC_PRINTEVENPAGEFLAG:
1262         case LyXRC::RC_PRINTEXSTRAOPTIONS:
1263         case LyXRC::RC_PRINTFILEEXTENSION:
1264         case LyXRC::RC_PRINTLANDSCAPEFLAG:
1265         case LyXRC::RC_PRINTODDPAGEFLAG:
1266         case LyXRC::RC_PRINTPAGERANGEFLAG:
1267         case LyXRC::RC_PRINTPAPERDIMENSIONFLAG:
1268         case LyXRC::RC_PRINTPAPERFLAG:
1269         case LyXRC::RC_PRINTREVERSEFLAG:
1270         case LyXRC::RC_PRINTSPOOL_COMMAND:
1271         case LyXRC::RC_PRINTSPOOL_PRINTERPREFIX:
1272         case LyXRC::RC_PRINTTOFILE:
1273         case LyXRC::RC_PRINTTOPRINTER:
1274         case LyXRC::RC_PRINT_ADAPTOUTPUT:
1275         case LyXRC::RC_PRINT_COMMAND:
1276         case LyXRC::RC_RTL_SUPPORT:
1277         case LyXRC::RC_SCREEN_DPI:
1278         case LyXRC::RC_SCREEN_FONT_ROMAN:
1279         case LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY:
1280         case LyXRC::RC_SCREEN_FONT_SANS:
1281         case LyXRC::RC_SCREEN_FONT_SANS_FOUNDRY:
1282         case LyXRC::RC_SCREEN_FONT_SCALABLE:
1283         case LyXRC::RC_SCREEN_FONT_SIZES:
1284         case LyXRC::RC_SCREEN_FONT_TYPEWRITER:
1285         case LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
1286         case LyXRC::RC_GEOMETRY_SESSION:
1287         case LyXRC::RC_SCREEN_ZOOM:
1288         case LyXRC::RC_SERVERPIPE:
1289         case LyXRC::RC_SET_COLOR:
1290         case LyXRC::RC_SHOW_BANNER:
1291         case LyXRC::RC_OPEN_BUFFERS_IN_TABS:
1292         case LyXRC::RC_SPELL_COMMAND:
1293         case LyXRC::RC_SPELLCHECKER:
1294         case LyXRC::RC_SPELLCHECK_CONTINUOUSLY:
1295         case LyXRC::RC_SPLITINDEX_COMMAND:
1296         case LyXRC::RC_TEMPDIRPATH:
1297         case LyXRC::RC_TEMPLATEPATH:
1298         case LyXRC::RC_TEX_ALLOWS_SPACES:
1299         case LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS:
1300                 if (lyxrc_orig.windows_style_tex_paths != lyxrc_new.windows_style_tex_paths) {
1301                         os::windows_style_tex_paths(lyxrc_new.windows_style_tex_paths);
1302                 }
1303         case LyXRC::RC_THESAURUSDIRPATH:
1304         case LyXRC::RC_UIFILE:
1305         case LyXRC::RC_USER_EMAIL:
1306         case LyXRC::RC_USER_NAME:
1307         case LyXRC::RC_USETEMPDIR:
1308         case LyXRC::RC_USE_ALT_LANG:
1309         case LyXRC::RC_USE_CONVERTER_CACHE:
1310         case LyXRC::RC_USE_ESC_CHARS:
1311         case LyXRC::RC_USE_INP_ENC:
1312         case LyXRC::RC_USE_PERS_DICT:
1313         case LyXRC::RC_USE_TOOLTIP:
1314         case LyXRC::RC_USE_PIXMAP_CACHE:
1315         case LyXRC::RC_USE_SPELL_LIB:
1316         case LyXRC::RC_VIEWDVI_PAPEROPTION:
1317         case LyXRC::RC_SORT_LAYOUTS:
1318         case LyXRC::RC_FULL_SCREEN_LIMIT:
1319         case LyXRC::RC_FULL_SCREEN_SCROLLBAR:
1320         case LyXRC::RC_FULL_SCREEN_MENUBAR:
1321         case LyXRC::RC_FULL_SCREEN_TABBAR:
1322         case LyXRC::RC_FULL_SCREEN_TOOLBARS:
1323         case LyXRC::RC_FULL_SCREEN_WIDTH:
1324         case LyXRC::RC_VISUAL_CURSOR:
1325         case LyXRC::RC_VIEWER:
1326         case LyXRC::RC_VIEWER_ALTERNATIVES:
1327         case LyXRC::RC_LAST:
1328                 break;
1329         }
1330 }
1331
1332 } // namespace anon
1333 } // namespace lyx