3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Alfredo Braunstein
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
9 * \author Angus Leeming
11 * \author André Pönitz
14 * \author Martin Vermeer
15 * \author Jürgen Vigna
17 * Full author contact details are available in file CREDITS.
25 #include "BranchList.h"
26 #include "buffer_funcs.h"
28 #include "BufferList.h"
29 #include "BufferParams.h"
30 #include "BufferView.h"
33 #include "Converter.h"
35 #include "CutAndPaste.h"
37 #include "DispatchResult.h"
39 #include "ErrorList.h"
41 #include "FuncRequest.h"
42 #include "FuncStatus.h"
44 #include "InsetIterator.h"
49 #include "LyXAction.h"
54 #include "Paragraph.h"
55 #include "ParagraphParameters.h"
56 #include "ParIterator.h"
60 #include "TextClassList.h"
61 #include "ToolbarBackend.h"
63 #include "insets/InsetBox.h"
64 #include "insets/InsetBranch.h"
65 #include "insets/InsetCommand.h"
66 #include "insets/InsetERT.h"
67 #include "insets/InsetExternal.h"
68 #include "insets/InsetFloat.h"
69 #include "insets/InsetListings.h"
70 #include "insets/InsetGraphics.h"
71 #include "insets/InsetInclude.h"
72 #include "insets/InsetNote.h"
73 #include "insets/InsetTabular.h"
74 #include "insets/InsetVSpace.h"
75 #include "insets/InsetWrap.h"
77 #include "frontends/alert.h"
78 #include "frontends/Application.h"
79 #include "frontends/FileDialog.h"
80 #include "frontends/FontLoader.h"
81 #include "frontends/KeySymbol.h"
82 #include "frontends/LyXView.h"
83 #include "frontends/Selection.h"
85 #include "support/environment.h"
86 #include "support/FileFilterList.h"
87 #include "support/FileName.h"
88 #include "support/filetools.h"
89 #include "support/lstrings.h"
90 #include "support/Path.h"
91 #include "support/Package.h"
92 #include "support/Systemcall.h"
93 #include "support/convert.h"
94 #include "support/os.h"
96 #include <boost/current_function.hpp>
101 using std::make_pair;
104 using std::istringstream;
105 using std::ostringstream;
111 using frontend::LyXView;
113 using support::absolutePath;
114 using support::addName;
115 using support::addPath;
116 using support::bformat;
117 using support::changeExtension;
118 using support::contains;
119 using support::FileFilterList;
120 using support::FileName;
121 using support::fileSearch;
122 using support::i18nLibFileSearch;
123 using support::makeDisplayPath;
124 using support::makeAbsPath;
125 using support::package;
126 using support::quoteName;
127 using support::rtrim;
128 using support::split;
129 using support::subst;
130 using support::Systemcall;
131 using support::token;
133 using support::prefixIs;
136 namespace Alert = frontend::Alert;
138 extern bool quitting;
144 bool import(LyXView * lv, FileName const & filename,
145 string const & format, ErrorList & errorList)
147 docstring const displaypath = makeDisplayPath(filename.absFilename());
148 lv->message(bformat(_("Importing %1$s..."), displaypath));
150 FileName const lyxfile(changeExtension(filename.absFilename(), ".lyx"));
152 string loader_format;
153 vector<string> loaders = theConverters().loaders();
154 if (find(loaders.begin(), loaders.end(), format) == loaders.end()) {
155 for (vector<string>::const_iterator it = loaders.begin();
156 it != loaders.end(); ++it) {
157 if (theConverters().isReachable(format, *it)) {
158 string const tofile =
159 changeExtension(filename.absFilename(),
160 formats.extension(*it));
161 if (!theConverters().convert(0, filename, FileName(tofile),
162 filename, format, *it, errorList))
168 if (loader_format.empty()) {
169 frontend::Alert::error(_("Couldn't import file"),
170 bformat(_("No information for importing the format %1$s."),
171 formats.prettyName(format)));
175 loader_format = format;
179 if (loader_format == "lyx") {
180 Buffer * buf = theLyXFunc().loadAndViewFile(lyxfile);
183 lv->message(_("file not imported!"));
190 Buffer * const b = newFile(lyxfile.absFilename(), string(), true);
195 bool as_paragraphs = loader_format == "textparagraph";
196 string filename2 = (loader_format == format) ? filename.absFilename()
197 : changeExtension(filename.absFilename(),
198 formats.extension(loader_format));
199 lv->view()->insertPlaintextFile(filename2, as_paragraphs);
200 lv->dispatch(FuncRequest(LFUN_MARK_OFF));
204 lv->message(_("imported."));
210 // This function runs "configure" and then rereads lyx.defaults to
211 // reconfigure the automatic settings.
212 void reconfigure(LyXView & lv, string const & option)
214 // emit message signal.
215 lv.message(_("Running configure..."));
217 // Run configure in user lyx directory
218 support::PathChanger p(package().user_support());
219 string configure_command = package().configure_command();
220 configure_command += option;
222 int ret = one.startscript(Systemcall::Wait, configure_command);
224 // emit message signal.
225 lv.message(_("Reloading configuration..."));
226 lyxrc.read(support::libFileSearch(string(), "lyxrc.defaults"));
227 // Re-read packages.lst
228 LaTeXFeatures::getAvailable();
231 Alert::information(_("System reconfiguration failed"),
232 _("The system reconfiguration has failed.\n"
233 "Default textclass is used but LyX may "
234 "not be able to work properly.\n"
235 "Please reconfigure again if needed."));
238 Alert::information(_("System reconfigured"),
239 _("The system has been reconfigured.\n"
240 "You need to restart LyX to make use of any\n"
241 "updated document class specifications."));
245 bool getLocalStatus(Cursor cursor, FuncRequest const & cmd, FuncStatus & status)
247 // Try to fix cursor in case it is broken.
248 cursor.fixIfBroken();
250 // This is, of course, a mess. Better create a new doc iterator and use
251 // this in Inset::getStatus. This might require an additional
252 // BufferView * arg, though (which should be avoided)
253 //Cursor safe = *this;
255 for ( ; cursor.depth(); cursor.pop()) {
256 //lyxerr << "\nCursor::getStatus: cmd: " << cmd << endl << *this << endl;
257 BOOST_ASSERT(cursor.idx() <= cursor.lastidx());
258 BOOST_ASSERT(cursor.pit() <= cursor.lastpit());
259 BOOST_ASSERT(cursor.pos() <= cursor.lastpos());
261 // The inset's getStatus() will return 'true' if it made
262 // a definitive decision on whether it want to handle the
263 // request or not. The result of this decision is put into
264 // the 'status' parameter.
265 if (cursor.inset().getStatus(cursor, cmd, status)) {
274 /** Return the change status at cursor position, taking in account the
275 * status at each level of the document iterator (a table in a deleted
276 * footnote is deleted).
277 * When \param outer is true, the top slice is not looked at.
279 Change::Type lookupChangeType(DocIterator const & dit, bool outer = false)
281 size_t const depth = dit.depth() - (outer ? 1 : 0);
283 for (size_t i = 0 ; i < depth ; ++i) {
284 CursorSlice const & slice = dit[i];
285 if (!slice.inset().inMathed()
286 && slice.pos() < slice.paragraph().size()) {
287 Change::Type const ch = slice.paragraph().lookupChange(slice.pos()).type;
288 if (ch != Change::UNCHANGED)
292 return Change::UNCHANGED;
299 : lyx_view_(0), encoded_last_key(0), meta_fake_bit(NoModifier)
304 void LyXFunc::initKeySequences(KeyMap * kb)
306 keyseq = KeySequence(kb, kb);
307 cancel_meta_seq = KeySequence(kb, kb);
311 void LyXFunc::setLyXView(LyXView * lv)
313 if (!quitting && lyx_view_ && lyx_view_->view() && lyx_view_ != lv)
314 // save current selection to the selection buffer to allow
315 // middle-button paste in another window
316 cap::saveSelection(lyx_view_->view()->cursor());
321 void LyXFunc::handleKeyFunc(kb_action action)
323 char_type c = encoded_last_key;
328 BOOST_ASSERT(lyx_view_ && lyx_view_->view());
329 lyx_view_->view()->getIntl().getTransManager().deadkey(
330 c, get_accent(action).accent, view()->cursor().innerText(), view()->cursor());
331 // Need to clear, in case the minibuffer calls these
334 // copied verbatim from do_accent_char
335 view()->cursor().resetAnchor();
336 view()->processUpdateFlags(Update::FitCursor);
340 void LyXFunc::gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer)
342 BOOST_ASSERT(lyx_view_);
343 if (!LyX::ref().session().bookmarks().isValid(idx))
345 BookmarksSection::Bookmark const & bm = LyX::ref().session().bookmarks().bookmark(idx);
346 BOOST_ASSERT(!bm.filename.empty());
347 string const file = bm.filename.absFilename();
348 // if the file is not opened, open it.
349 if (!theBufferList().exists(file)) {
351 dispatch(FuncRequest(LFUN_FILE_OPEN, file));
355 // open may fail, so we need to test it again
356 if (!theBufferList().exists(file))
359 // if the current buffer is not that one, switch to it.
360 if (lyx_view_->buffer()->absFileName() != file) {
363 dispatch(FuncRequest(LFUN_BUFFER_SWITCH, file));
365 // moveToPosition try paragraph id first and then paragraph (pit, pos).
366 if (!view()->moveToPosition(bm.bottom_pit, bm.bottom_pos,
367 bm.top_id, bm.top_pos))
370 // Cursor jump succeeded!
371 Cursor const & cur = view()->cursor();
372 pit_type new_pit = cur.pit();
373 pos_type new_pos = cur.pos();
374 int new_id = cur.paragraph().id();
376 // if bottom_pit, bottom_pos or top_id has been changed, update bookmark
377 // see http://bugzilla.lyx.org/show_bug.cgi?id=3092
378 if (bm.bottom_pit != new_pit || bm.bottom_pos != new_pos
379 || bm.top_id != new_id) {
380 const_cast<BookmarksSection::Bookmark &>(bm).updatePos(
381 new_pit, new_pos, new_id);
386 void LyXFunc::processKeySym(KeySymbol const & keysym, KeyModifier state)
388 LYXERR(Debug::KEY, "KeySym is " << keysym.getSymbolName());
390 // Do nothing if we have nothing (JMarc)
391 if (!keysym.isOK()) {
392 LYXERR(Debug::KEY, "Empty kbd action (probably composing)");
393 lyx_view_->restartCursor();
397 if (keysym.isModifier()) {
398 LYXERR(Debug::KEY, "isModifier true");
399 lyx_view_->restartCursor();
403 //Encoding const * encoding = view()->cursor().getEncoding();
404 //encoded_last_key = keysym.getISOEncoded(encoding ? encoding->name() : "");
405 // FIXME: encoded_last_key shadows the member variable of the same
406 // name. Is that intended?
407 char_type encoded_last_key = keysym.getUCSEncoded();
409 // Do a one-deep top-level lookup for
410 // cancel and meta-fake keys. RVDK_PATCH_5
411 cancel_meta_seq.reset();
413 FuncRequest func = cancel_meta_seq.addkey(keysym, state);
414 LYXERR(Debug::KEY, BOOST_CURRENT_FUNCTION
415 << " action first set to [" << func.action << ']');
417 // When not cancel or meta-fake, do the normal lookup.
418 // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards.
419 // Mostly, meta_fake_bit = NoModifier. RVDK_PATCH_5.
420 if ((func.action != LFUN_CANCEL) && (func.action != LFUN_META_PREFIX)) {
421 // remove Caps Lock and Mod2 as a modifiers
422 func = keyseq.addkey(keysym, (state | meta_fake_bit));
423 LYXERR(Debug::KEY, BOOST_CURRENT_FUNCTION
424 << "action now set to [" << func.action << ']');
427 // Dont remove this unless you know what you are doing.
428 meta_fake_bit = NoModifier;
430 // Can this happen now ?
431 if (func.action == LFUN_NOACTION)
432 func = FuncRequest(LFUN_COMMAND_PREFIX);
434 LYXERR(Debug::KEY, BOOST_CURRENT_FUNCTION
435 << " Key [action=" << func.action << "]["
436 << to_utf8(keyseq.print(KeySequence::Portable)) << ']');
438 // already here we know if it any point in going further
439 // why not return already here if action == -1 and
440 // num_bytes == 0? (Lgb)
442 if (keyseq.length() > 1)
443 lyx_view_->message(keyseq.print(KeySequence::ForGui));
446 // Maybe user can only reach the key via holding down shift.
447 // Let's see. But only if shift is the only modifier
448 if (func.action == LFUN_UNKNOWN_ACTION && state == ShiftModifier) {
449 LYXERR(Debug::KEY, "Trying without shift");
450 func = keyseq.addkey(keysym, NoModifier);
451 LYXERR(Debug::KEY, "Action now " << func.action);
454 if (func.action == LFUN_UNKNOWN_ACTION) {
455 // Hmm, we didn't match any of the keysequences. See
456 // if it's normal insertable text not already covered
458 if (keysym.isText() && keyseq.length() == 1) {
459 LYXERR(Debug::KEY, "isText() is true, inserting.");
460 func = FuncRequest(LFUN_SELF_INSERT,
461 FuncRequest::KEYBOARD);
463 LYXERR(Debug::KEY, "Unknown, !isText() - giving up");
464 lyx_view_->message(_("Unknown function."));
465 lyx_view_->restartCursor();
470 if (func.action == LFUN_SELF_INSERT) {
471 if (encoded_last_key != 0) {
472 docstring const arg(1, encoded_last_key);
473 dispatch(FuncRequest(LFUN_SELF_INSERT, arg,
474 FuncRequest::KEYBOARD));
475 LYXERR(Debug::KEY, "SelfInsert arg[`" << to_utf8(arg) << "']");
481 lyx_view_->restartCursor();
485 FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
487 //lyxerr << "LyXFunc::getStatus: cmd: " << cmd << endl;
490 Buffer * buf = lyx_view_? lyx_view_->buffer() : 0;
492 if (cmd.action == LFUN_NOACTION) {
493 flag.message(from_utf8(N_("Nothing to do")));
498 switch (cmd.action) {
499 case LFUN_UNKNOWN_ACTION:
500 #ifndef HAVE_LIBAIKSAURUS
501 case LFUN_THESAURUS_ENTRY:
511 if (flag.unknown()) {
512 flag.message(from_utf8(N_("Unknown action")));
516 if (!flag.enabled()) {
517 if (flag.message().empty())
518 flag.message(from_utf8(N_("Command disabled")));
522 // Check whether we need a buffer
523 if (!lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer) && !buf) {
525 flag.message(from_utf8(N_("Command not allowed with"
526 "out any document open")));
531 // I would really like to avoid having this switch and rather try to
532 // encode this in the function itself.
533 // -- And I'd rather let an inset decide which LFUNs it is willing
534 // to handle (Andre')
536 switch (cmd.action) {
538 case LFUN_DIALOG_TOGGLE:
539 case LFUN_DIALOG_SHOW:
540 case LFUN_DIALOG_UPDATE:
541 case LFUN_TOOLBAR_TOGGLE:
543 return lyx_view_->getStatus(cmd);
547 case LFUN_BUFFER_TOGGLE_READ_ONLY:
548 flag.setOnOff(buf->isReadonly());
551 case LFUN_BUFFER_SWITCH:
552 // toggle on the current buffer, but do not toggle off
553 // the other ones (is that a good idea?)
554 if (buf && to_utf8(cmd.argument()) == buf->absFileName())
558 case LFUN_BUFFER_EXPORT:
559 enable = cmd.argument() == "custom"
560 || buf->isExportable(to_utf8(cmd.argument()));
563 case LFUN_BUFFER_CHKTEX:
564 enable = buf->isLatex() && !lyxrc.chktex_command.empty();
567 case LFUN_BUILD_PROGRAM:
568 enable = buf->isExportable("program");
571 case LFUN_VC_REGISTER:
572 enable = !buf->lyxvc().inUse();
574 case LFUN_VC_CHECK_IN:
575 enable = buf->lyxvc().inUse() && !buf->isReadonly();
577 case LFUN_VC_CHECK_OUT:
578 enable = buf->lyxvc().inUse() && buf->isReadonly();
581 case LFUN_VC_UNDO_LAST:
582 enable = buf->lyxvc().inUse();
584 case LFUN_BUFFER_RELOAD:
585 enable = !buf->isUnnamed() && buf->fileName().exists()
586 && (!buf->isClean() || buf->isExternallyModified(Buffer::timestamp_method));
589 case LFUN_INSET_APPLY: {
594 string const name = cmd.getArg(0);
595 Inset * inset = lyx_view_->getOpenInset(name);
597 FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
599 if (!inset->getStatus(view()->cursor(), fr, fs)) {
600 // Every inset is supposed to handle this
605 FuncRequest fr(LFUN_INSET_INSERT, cmd.argument());
606 flag |= getStatus(fr);
608 enable = flag.enabled();
612 case LFUN_CITATION_INSERT: {
613 FuncRequest fr(LFUN_INSET_INSERT, "citation");
614 enable = getStatus(fr).enabled();
618 case LFUN_BUFFER_WRITE: {
619 enable = lyx_view_->buffer()->isUnnamed()
620 || !lyx_view_->buffer()->isClean();
625 case LFUN_BUFFER_WRITE_ALL: {
626 // We enable the command only if there are some modified buffers
627 Buffer * first = theBufferList().first();
628 bool modified = false;
632 // We cannot use a for loop as the buffer list is a cycle.
638 b = theBufferList().next(b);
639 } while (b != first);
647 case LFUN_BOOKMARK_GOTO: {
648 const unsigned int num = convert<unsigned int>(to_utf8(cmd.argument()));
649 enable = LyX::ref().session().bookmarks().isValid(num);
653 case LFUN_BOOKMARK_CLEAR:
654 enable = LyX::ref().session().bookmarks().size() > 0;
657 case LFUN_WINDOW_CLOSE:
658 enable = theApp()->viewCount() > 0;
661 // this one is difficult to get right. As a half-baked
662 // solution, we consider only the first action of the sequence
663 case LFUN_COMMAND_SEQUENCE: {
664 // argument contains ';'-terminated commands
665 string const firstcmd = token(to_utf8(cmd.argument()), ';', 0);
666 FuncRequest func(lyxaction.lookupFunc(firstcmd));
667 func.origin = cmd.origin;
668 flag = getStatus(func);
674 std::string name = to_utf8(cmd.argument());
675 if (LyX::ref().topLevelCmdDef().lock(name, func)) {
676 func.origin = cmd.origin;
677 flag = getStatus(func);
678 LyX::ref().topLevelCmdDef().release(name);
680 // catch recursion or unknown command definiton
681 // all operations until the recursion or unknown command
682 // definiton occures are performed, so set the state to enabled
688 case LFUN_BUFFER_NEW:
689 case LFUN_BUFFER_NEW_TEMPLATE:
690 case LFUN_WORD_FIND_FORWARD:
691 case LFUN_WORD_FIND_BACKWARD:
692 case LFUN_COMMAND_PREFIX:
693 case LFUN_COMMAND_EXECUTE:
695 case LFUN_META_PREFIX:
696 case LFUN_BUFFER_CLOSE:
697 case LFUN_BUFFER_WRITE_AS:
698 case LFUN_BUFFER_UPDATE:
699 case LFUN_BUFFER_VIEW:
700 case LFUN_MASTER_BUFFER_UPDATE:
701 case LFUN_MASTER_BUFFER_VIEW:
702 case LFUN_BUFFER_IMPORT:
703 case LFUN_BUFFER_AUTO_SAVE:
704 case LFUN_RECONFIGURE:
708 case LFUN_DROP_LAYOUTS_CHOICE:
710 case LFUN_SERVER_GET_NAME:
711 case LFUN_SERVER_NOTIFY:
712 case LFUN_SERVER_GOTO_FILE_ROW:
713 case LFUN_DIALOG_HIDE:
714 case LFUN_DIALOG_DISCONNECT_INSET:
715 case LFUN_BUFFER_CHILD_OPEN:
716 case LFUN_TOGGLE_CURSOR_FOLLOWS_SCROLLBAR:
717 case LFUN_KEYMAP_OFF:
718 case LFUN_KEYMAP_PRIMARY:
719 case LFUN_KEYMAP_SECONDARY:
720 case LFUN_KEYMAP_TOGGLE:
722 case LFUN_BUFFER_EXPORT_CUSTOM:
723 case LFUN_BUFFER_PRINT:
724 case LFUN_PREFERENCES_SAVE:
725 case LFUN_SCREEN_FONT_UPDATE:
728 case LFUN_EXTERNAL_EDIT:
729 case LFUN_GRAPHICS_EDIT:
730 case LFUN_ALL_INSETS_TOGGLE:
731 case LFUN_BUFFER_LANGUAGE:
732 case LFUN_TEXTCLASS_APPLY:
733 case LFUN_TEXTCLASS_LOAD:
734 case LFUN_BUFFER_SAVE_AS_DEFAULT:
735 case LFUN_BUFFER_PARAMS_APPLY:
736 case LFUN_LAYOUT_MODULES_CLEAR:
737 case LFUN_LAYOUT_MODULE_ADD:
738 case LFUN_LAYOUT_RELOAD:
739 case LFUN_LYXRC_APPLY:
740 case LFUN_BUFFER_NEXT:
741 case LFUN_BUFFER_PREVIOUS:
742 case LFUN_WINDOW_NEW:
744 // these are handled in our dispatch()
752 if (!getLocalStatus(view()->cursor(), cmd, flag))
753 flag = view()->getStatus(cmd);
759 // Can we use a readonly buffer?
760 if (buf && buf->isReadonly()
761 && !lyxaction.funcHasFlag(cmd.action, LyXAction::ReadOnly)
762 && !lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer)) {
763 flag.message(from_utf8(N_("Document is read-only")));
767 // Are we in a DELETED change-tracking region?
769 && lookupChangeType(view()->cursor(), true) == Change::DELETED
770 && !lyxaction.funcHasFlag(cmd.action, LyXAction::ReadOnly)
771 && !lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer)) {
772 flag.message(from_utf8(N_("This portion of the document is deleted.")));
776 // the default error message if we disable the command
777 if (!flag.enabled() && flag.message().empty())
778 flag.message(from_utf8(N_("Command disabled")));
784 bool LyXFunc::ensureBufferClean(BufferView * bv)
786 Buffer & buf = bv->buffer();
790 docstring const file = buf.fileName().displayName(30);
791 docstring text = bformat(_("The document %1$s has unsaved "
792 "changes.\n\nDo you want to save "
793 "the document?"), file);
794 int const ret = Alert::prompt(_("Save changed document?"),
795 text, 0, 1, _("&Save"),
799 dispatch(FuncRequest(LFUN_BUFFER_WRITE));
801 return buf.isClean();
807 void showPrintError(string const & name)
809 docstring str = bformat(_("Could not print the document %1$s.\n"
810 "Check that your printer is set up correctly."),
811 makeDisplayPath(name, 50));
812 Alert::error(_("Print document failed"), str);
816 void loadTextClass(string const & name)
818 std::pair<bool, textclass_type> const tc_pair =
819 textclasslist.numberOfClass(name);
821 if (!tc_pair.first) {
822 lyxerr << "Document class \"" << name
823 << "\" does not exist."
828 textclass_type const tc = tc_pair.second;
830 if (!textclasslist[tc].load()) {
831 docstring s = bformat(_("The document class %1$s."
832 "could not be loaded."),
833 from_utf8(textclasslist[tc].name()));
834 Alert::error(_("Could not load class"), s);
839 void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new);
844 void LyXFunc::dispatch(FuncRequest const & cmd)
846 string const argument = to_utf8(cmd.argument());
847 kb_action const action = cmd.action;
849 LYXERR(Debug::ACTION, "\nLyXFunc::dispatch: cmd: " << cmd);
850 //lyxerr << "LyXFunc::dispatch: cmd: " << cmd << endl;
852 // we have not done anything wrong yet.
854 dispatch_buffer.erase();
856 // redraw the screen at the end (first of the two drawing steps).
857 //This is done unless explicitely requested otherwise
858 Update::flags updateFlags = Update::FitCursor;
860 FuncStatus const flag = getStatus(cmd);
861 if (!flag.enabled()) {
862 // We cannot use this function here
863 LYXERR(Debug::ACTION, "LyXFunc::dispatch: "
864 << lyxaction.getActionName(action)
865 << " [" << action << "] is disabled at this location");
866 setErrorMessage(flag.message());
869 // Let lyx_view_ dispatch its own actions.
870 case LFUN_COMMAND_EXECUTE:
871 case LFUN_DROP_LAYOUTS_CHOICE:
873 case LFUN_TOOLBAR_TOGGLE:
874 case LFUN_DIALOG_UPDATE:
875 case LFUN_DIALOG_TOGGLE:
876 case LFUN_DIALOG_DISCONNECT_INSET:
877 case LFUN_DIALOG_HIDE:
878 BOOST_ASSERT(lyx_view_);
879 lyx_view_->dispatch(cmd);
882 case LFUN_WORD_FIND_FORWARD:
883 case LFUN_WORD_FIND_BACKWARD: {
884 BOOST_ASSERT(lyx_view_ && lyx_view_->view());
885 static docstring last_search;
886 docstring searched_string;
888 if (!cmd.argument().empty()) {
889 last_search = cmd.argument();
890 searched_string = cmd.argument();
892 searched_string = last_search;
895 if (searched_string.empty())
898 bool const fw = action == LFUN_WORD_FIND_FORWARD;
899 docstring const data =
900 find2string(searched_string, true, false, fw);
901 find(view(), FuncRequest(LFUN_WORD_FIND, data));
905 case LFUN_COMMAND_PREFIX:
906 BOOST_ASSERT(lyx_view_);
907 lyx_view_->message(keyseq.printOptions(true));
911 BOOST_ASSERT(lyx_view_ && lyx_view_->view());
913 meta_fake_bit = NoModifier;
914 if (lyx_view_->buffer())
915 // cancel any selection
916 dispatch(FuncRequest(LFUN_MARK_OFF));
917 setMessage(from_ascii(N_("Cancel")));
920 case LFUN_META_PREFIX:
921 meta_fake_bit = AltModifier;
922 setMessage(keyseq.print(KeySequence::ForGui));
925 case LFUN_BUFFER_TOGGLE_READ_ONLY: {
926 BOOST_ASSERT(lyx_view_ && lyx_view_->view() && lyx_view_->buffer());
927 Buffer * buf = lyx_view_->buffer();
928 if (buf->lyxvc().inUse())
929 buf->lyxvc().toggleReadOnly();
931 buf->setReadonly(!lyx_view_->buffer()->isReadonly());
935 // --- Menus -----------------------------------------------
936 case LFUN_BUFFER_NEW:
937 menuNew(argument, false);
938 updateFlags = Update::None;
941 case LFUN_BUFFER_NEW_TEMPLATE:
942 menuNew(argument, true);
943 updateFlags = Update::None;
946 case LFUN_BUFFER_CLOSE:
948 updateFlags = Update::None;
951 case LFUN_BUFFER_WRITE:
952 BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
953 if (!lyx_view_->buffer()->isUnnamed()) {
954 docstring const str = bformat(_("Saving document %1$s..."),
955 makeDisplayPath(lyx_view_->buffer()->absFileName()));
956 lyx_view_->message(str);
957 lyx_view_->buffer()->menuWrite();
958 lyx_view_->message(str + _(" done."));
960 lyx_view_->buffer()->writeAs();
962 updateFlags = Update::None;
965 case LFUN_BUFFER_WRITE_AS:
966 BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
967 lyx_view_->buffer()->writeAs(argument);
968 updateFlags = Update::None;
971 case LFUN_BUFFER_WRITE_ALL: {
972 Buffer * first = theBufferList().first();
975 lyx_view_->message(_("Saving all documents..."));
977 // We cannot use a for loop as the buffer list cycles.
980 if (!b->isUnnamed()) {
982 lyxerr[Debug::ACTION] << "Saved " << b->absFileName() << endl;
986 b = theBufferList().next(b);
987 } while (b != first);
988 lyx_view_->message(_("All documents saved."));
991 updateFlags = Update::None;
995 case LFUN_BUFFER_RELOAD: {
996 BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
997 docstring const file = makeDisplayPath(lyx_view_->buffer()->absFileName(), 20);
998 docstring text = bformat(_("Any changes will be lost. Are you sure "
999 "you want to revert to the saved version of the document %1$s?"), file);
1000 int const ret = Alert::prompt(_("Revert to saved document?"),
1001 text, 1, 1, _("&Revert"), _("&Cancel"));
1008 case LFUN_BUFFER_UPDATE:
1009 BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
1010 lyx_view_->buffer()->doExport(argument, true);
1013 case LFUN_BUFFER_VIEW:
1014 BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
1015 lyx_view_->buffer()->preview(argument);
1018 case LFUN_MASTER_BUFFER_UPDATE:
1019 BOOST_ASSERT(lyx_view_ && lyx_view_->buffer() && lyx_view_->buffer()->masterBuffer());
1020 lyx_view_->buffer()->masterBuffer()->doExport(argument, true);
1023 case LFUN_MASTER_BUFFER_VIEW:
1024 BOOST_ASSERT(lyx_view_ && lyx_view_->buffer() && lyx_view_->buffer()->masterBuffer());
1025 lyx_view_->buffer()->masterBuffer()->preview(argument);
1028 case LFUN_BUILD_PROGRAM:
1029 BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
1030 lyx_view_->buffer()->doExport("program", true);
1033 case LFUN_BUFFER_CHKTEX:
1034 BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
1035 lyx_view_->buffer()->runChktex();
1038 case LFUN_BUFFER_EXPORT:
1039 BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
1040 if (argument == "custom")
1041 lyx_view_->showDialog("sendto", string());
1043 lyx_view_->buffer()->doExport(argument, false);
1046 case LFUN_BUFFER_EXPORT_CUSTOM: {
1047 BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
1049 string command = split(argument, format_name, ' ');
1050 Format const * format = formats.getFormat(format_name);
1052 lyxerr << "Format \"" << format_name
1053 << "\" not recognized!"
1058 Buffer * buffer = lyx_view_->buffer();
1060 // The name of the file created by the conversion process
1063 // Output to filename
1064 if (format->name() == "lyx") {
1065 string const latexname = buffer->latexName(false);
1066 filename = changeExtension(latexname,
1067 format->extension());
1068 filename = addName(buffer->temppath(), filename);
1070 if (!buffer->writeFile(FileName(filename)))
1074 buffer->doExport(format_name, true, filename);
1077 // Substitute $$FName for filename
1078 if (!contains(command, "$$FName"))
1079 command = "( " + command + " ) < $$FName";
1080 command = subst(command, "$$FName", filename);
1082 // Execute the command in the background
1084 call.startscript(Systemcall::DontWait, command);
1088 case LFUN_BUFFER_PRINT: {
1089 BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
1090 // FIXME: cmd.getArg() might fail if one of the arguments
1091 // contains double quotes
1092 string target = cmd.getArg(0);
1093 string target_name = cmd.getArg(1);
1094 string command = cmd.getArg(2);
1097 || target_name.empty()
1098 || command.empty()) {
1099 lyxerr << "Unable to parse \""
1100 << argument << '"' << endl;
1103 if (target != "printer" && target != "file") {
1104 lyxerr << "Unrecognized target \""
1105 << target << '"' << endl;
1109 Buffer * buffer = lyx_view_->buffer();
1111 if (!buffer->doExport("dvi", true)) {
1112 showPrintError(buffer->absFileName());
1116 // Push directory path.
1117 string const path = buffer->temppath();
1118 // Prevent the compiler from optimizing away p
1120 support::PathChanger p(pp);
1122 // there are three cases here:
1123 // 1. we print to a file
1124 // 2. we print directly to a printer
1125 // 3. we print using a spool command (print to file first)
1128 string const dviname =
1129 changeExtension(buffer->latexName(true), "dvi");
1131 if (target == "printer") {
1132 if (!lyxrc.print_spool_command.empty()) {
1133 // case 3: print using a spool
1134 string const psname =
1135 changeExtension(dviname,".ps");
1136 command += ' ' + lyxrc.print_to_file
1139 + quoteName(dviname);
1142 lyxrc.print_spool_command + ' ';
1143 if (target_name != "default") {
1144 command2 += lyxrc.print_spool_printerprefix
1148 command2 += quoteName(psname);
1150 // If successful, then spool command
1151 res = one.startscript(
1156 res = one.startscript(
1157 Systemcall::DontWait,
1160 // case 2: print directly to a printer
1161 if (target_name != "default")
1162 command += ' ' + lyxrc.print_to_printer + target_name + ' ';
1163 res = one.startscript(
1164 Systemcall::DontWait,
1165 command + quoteName(dviname));
1169 // case 1: print to a file
1170 FileName const filename(makeAbsPath(target_name,
1171 lyx_view_->buffer()->filePath()));
1172 FileName const dvifile(makeAbsPath(dviname, path));
1173 if (filename.exists()) {
1174 docstring text = bformat(
1175 _("The file %1$s already exists.\n\n"
1176 "Do you want to overwrite that file?"),
1177 makeDisplayPath(filename.absFilename()));
1178 if (Alert::prompt(_("Overwrite file?"),
1179 text, 0, 1, _("&Overwrite"), _("&Cancel")) != 0)
1182 command += ' ' + lyxrc.print_to_file
1183 + quoteName(filename.toFilesystemEncoding())
1185 + quoteName(dvifile.toFilesystemEncoding());
1186 res = one.startscript(Systemcall::DontWait,
1191 showPrintError(buffer->absFileName());
1195 case LFUN_BUFFER_IMPORT:
1200 // quitting is triggered by the gui code
1201 // (leaving the event loop).
1202 lyx_view_->message(from_utf8(N_("Exiting.")));
1203 if (theBufferList().quitWriteAll())
1204 theApp()->closeAllViews();
1207 case LFUN_BUFFER_AUTO_SAVE:
1208 lyx_view_->buffer()->autoSave();
1211 case LFUN_RECONFIGURE:
1212 BOOST_ASSERT(lyx_view_);
1213 // argument is any additional parameter to the configure.py command
1214 reconfigure(*lyx_view_, argument);
1217 case LFUN_HELP_OPEN: {
1218 BOOST_ASSERT(lyx_view_);
1219 string const arg = argument;
1221 setErrorMessage(from_ascii(N_("Missing argument")));
1224 FileName const fname = i18nLibFileSearch("doc", arg, "lyx");
1225 if (fname.empty()) {
1226 lyxerr << "LyX: unable to find documentation file `"
1227 << arg << "'. Bad installation?" << endl;
1230 lyx_view_->message(bformat(_("Opening help file %1$s..."),
1231 makeDisplayPath(fname.absFilename())));
1232 Buffer * buf = loadAndViewFile(fname, false);
1235 lyx_view_->setBuffer(buf);
1236 lyx_view_->errors("Parse");
1238 updateFlags = Update::None;
1242 // --- version control -------------------------------
1243 case LFUN_VC_REGISTER:
1244 BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
1245 if (!ensureBufferClean(view()))
1247 if (!lyx_view_->buffer()->lyxvc().inUse()) {
1248 lyx_view_->buffer()->lyxvc().registrer();
1251 updateFlags = Update::Force;
1254 case LFUN_VC_CHECK_IN:
1255 BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
1256 if (!ensureBufferClean(view()))
1258 if (lyx_view_->buffer()->lyxvc().inUse()
1259 && !lyx_view_->buffer()->isReadonly()) {
1260 lyx_view_->buffer()->lyxvc().checkIn();
1265 case LFUN_VC_CHECK_OUT:
1266 BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
1267 if (!ensureBufferClean(view()))
1269 if (lyx_view_->buffer()->lyxvc().inUse()
1270 && lyx_view_->buffer()->isReadonly()) {
1271 lyx_view_->buffer()->lyxvc().checkOut();
1276 case LFUN_VC_REVERT:
1277 BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
1278 lyx_view_->buffer()->lyxvc().revert();
1282 case LFUN_VC_UNDO_LAST:
1283 BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
1284 lyx_view_->buffer()->lyxvc().undoLast();
1288 // --- buffers ----------------------------------------
1289 case LFUN_BUFFER_SWITCH:
1290 BOOST_ASSERT(lyx_view_);
1291 lyx_view_->setBuffer(theBufferList().getBuffer(argument));
1292 updateFlags = Update::None;
1295 case LFUN_BUFFER_NEXT:
1296 BOOST_ASSERT(lyx_view_);
1297 lyx_view_->setBuffer(theBufferList().next(lyx_view_->buffer()));
1298 updateFlags = Update::None;
1301 case LFUN_BUFFER_PREVIOUS:
1302 BOOST_ASSERT(lyx_view_);
1303 lyx_view_->setBuffer(theBufferList().previous(lyx_view_->buffer()));
1304 updateFlags = Update::None;
1307 case LFUN_FILE_NEW: {
1308 BOOST_ASSERT(lyx_view_);
1310 string tmpname = split(argument, name, ':'); // Split filename
1311 Buffer * const b = newFile(name, tmpname);
1313 lyx_view_->setBuffer(b);
1314 updateFlags = Update::None;
1318 case LFUN_FILE_OPEN:
1319 BOOST_ASSERT(lyx_view_);
1321 updateFlags = Update::None;
1324 // --- lyxserver commands ----------------------------
1325 case LFUN_SERVER_GET_NAME:
1326 BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
1327 setMessage(from_utf8(lyx_view_->buffer()->absFileName()));
1328 LYXERR(Debug::INFO, "FNAME["
1329 << lyx_view_->buffer()->absFileName() << ']');
1332 case LFUN_SERVER_NOTIFY:
1333 dispatch_buffer = keyseq.print(KeySequence::Portable);
1334 theServer().notifyClient(to_utf8(dispatch_buffer));
1337 case LFUN_SERVER_GOTO_FILE_ROW: {
1338 BOOST_ASSERT(lyx_view_);
1341 istringstream is(argument);
1342 is >> file_name >> row;
1344 bool loaded = false;
1345 if (prefixIs(file_name, package().temp_dir().absFilename()))
1346 // Needed by inverse dvi search. If it is a file
1347 // in tmpdir, call the apropriated function
1348 buf = theBufferList().getBufferFromTmp(file_name);
1350 // Must replace extension of the file to be .lyx
1351 // and get full path
1352 FileName const s = fileSearch(string(), changeExtension(file_name, ".lyx"), "lyx");
1353 // Either change buffer or load the file
1354 if (theBufferList().exists(s.absFilename()))
1355 buf = theBufferList().getBuffer(s.absFilename());
1357 buf = loadAndViewFile(s);
1363 updateFlags = Update::None;
1368 lyx_view_->setBuffer(buf);
1369 view()->setCursorFromRow(row);
1371 lyx_view_->errors("Parse");
1372 updateFlags = Update::FitCursor;
1377 case LFUN_DIALOG_SHOW_NEW_INSET: {
1378 BOOST_ASSERT(lyx_view_);
1379 string const name = cmd.getArg(0);
1380 InsetCode code = insetCode(name);
1381 string data = trim(to_utf8(cmd.argument()).substr(name.size()));
1382 bool insetCodeOK = true;
1391 case HYPERLINK_CODE: {
1392 InsetCommandParams p(code);
1393 data = InsetCommandMailer::params2string(name, p);
1396 case INCLUDE_CODE: {
1397 // data is the include type: one of "include",
1398 // "input", "verbatiminput" or "verbatiminput*"
1400 // default type is requested
1402 InsetCommandParams p(INCLUDE_CODE, data);
1403 data = InsetCommandMailer::params2string("include", p);
1407 // \c data == "Boxed" || "Frameless" etc
1408 InsetBoxParams p(data);
1409 data = InsetBoxMailer::params2string(p);
1413 InsetBranchParams p;
1414 data = InsetBranchMailer::params2string(p);
1418 InsetCommandParams p(CITE_CODE);
1419 data = InsetCommandMailer::params2string(name, p);
1423 data = InsetERTMailer::params2string(InsetCollapsable::Open);
1426 case EXTERNAL_CODE: {
1427 InsetExternalParams p;
1428 Buffer const & buffer = *lyx_view_->buffer();
1429 data = InsetExternalMailer::params2string(p, buffer);
1434 data = InsetFloatMailer::params2string(p);
1437 case LISTINGS_CODE: {
1438 InsetListingsParams p;
1439 data = InsetListingsMailer::params2string(p);
1442 case GRAPHICS_CODE: {
1443 InsetGraphicsParams p;
1444 Buffer const & buffer = *lyx_view_->buffer();
1445 data = InsetGraphicsMailer::params2string(p, buffer);
1450 data = InsetNoteMailer::params2string(p);
1455 data = InsetVSpaceMailer::params2string(space);
1460 data = InsetWrapMailer::params2string(p);
1464 lyxerr << "Inset type '" << name <<
1465 "' not recognized in LFUN_DIALOG_SHOW_NEW_INSET" << std:: endl;
1466 insetCodeOK = false;
1468 } // end switch(code)
1470 lyx_view_->showDialog(name, data, 0);
1474 case LFUN_CITATION_INSERT: {
1475 BOOST_ASSERT(lyx_view_);
1476 if (!argument.empty()) {
1477 // we can have one optional argument, delimited by '|'
1478 // citation-insert <key>|<text_before>
1479 // this should be enhanced to also support text_after
1480 // and citation style
1481 string arg = argument;
1483 if (contains(argument, "|")) {
1484 arg = token(argument, '|', 0);
1485 opt1 = token(argument, '|', 1);
1487 InsetCommandParams icp(CITE_CODE);
1488 icp["key"] = from_utf8(arg);
1490 icp["before"] = from_utf8(opt1);
1491 string icstr = InsetCommandMailer::params2string("citation", icp);
1492 FuncRequest fr(LFUN_INSET_INSERT, icstr);
1495 dispatch(FuncRequest(LFUN_DIALOG_SHOW_NEW_INSET, "citation"));
1499 case LFUN_BUFFER_CHILD_OPEN: {
1500 BOOST_ASSERT(lyx_view_ && lyx_view_->buffer());
1501 Buffer * parent = lyx_view_->buffer();
1502 FileName filename = makeAbsPath(argument, parent->filePath());
1503 view()->saveBookmark(false);
1505 bool parsed = false;
1506 if (theBufferList().exists(filename.absFilename())) {
1507 child = theBufferList().getBuffer(filename.absFilename());
1509 setMessage(bformat(_("Opening child document %1$s..."),
1510 makeDisplayPath(filename.absFilename())));
1511 child = loadAndViewFile(filename, true);
1515 // Set the parent name of the child document.
1516 // This makes insertion of citations and references in the child work,
1517 // when the target is in the parent or another child document.
1518 child->setParentName(parent->absFileName());
1519 updateLabels(*child->masterBuffer());
1520 lyx_view_->setBuffer(child);
1522 lyx_view_->errors("Parse");
1525 // If a screen update is required (in case where auto_open is false),
1526 // setBuffer() would have taken care of it already. Otherwise we shall
1527 // reset the update flag because it can cause a circular problem.
1529 updateFlags = Update::None;
1533 case LFUN_TOGGLE_CURSOR_FOLLOWS_SCROLLBAR:
1534 BOOST_ASSERT(lyx_view_);
1535 lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
1538 case LFUN_KEYMAP_OFF:
1539 BOOST_ASSERT(lyx_view_ && lyx_view_->view());
1540 lyx_view_->view()->getIntl().keyMapOn(false);
1543 case LFUN_KEYMAP_PRIMARY:
1544 BOOST_ASSERT(lyx_view_ && lyx_view_->view());
1545 lyx_view_->view()->getIntl().keyMapPrim();
1548 case LFUN_KEYMAP_SECONDARY:
1549 BOOST_ASSERT(lyx_view_ && lyx_view_->view());
1550 lyx_view_->view()->getIntl().keyMapSec();
1553 case LFUN_KEYMAP_TOGGLE:
1554 BOOST_ASSERT(lyx_view_ && lyx_view_->view());
1555 lyx_view_->view()->getIntl().toggleKeyMap();
1561 string rest = split(argument, countstr, ' ');
1562 istringstream is(countstr);
1565 lyxerr << "repeat: count: " << count << " cmd: " << rest << endl;
1566 for (int i = 0; i < count; ++i)
1567 dispatch(lyxaction.lookupFunc(rest));
1571 case LFUN_COMMAND_SEQUENCE: {
1572 // argument contains ';'-terminated commands
1573 string arg = argument;
1574 while (!arg.empty()) {
1576 arg = split(arg, first, ';');
1577 FuncRequest func(lyxaction.lookupFunc(first));
1578 func.origin = cmd.origin;
1586 if (LyX::ref().topLevelCmdDef().lock(argument, func)) {
1587 func.origin = cmd.origin;
1589 LyX::ref().topLevelCmdDef().release(argument);
1591 if (func.action == LFUN_UNKNOWN_ACTION) {
1592 // unknown command definition
1593 lyxerr << "Warning: unknown command definition `"
1597 // recursion detected
1598 lyxerr << "Warning: Recursion in the command definition `"
1599 << argument << "' detected"
1606 case LFUN_PREFERENCES_SAVE: {
1607 lyxrc.write(makeAbsPath("preferences",
1608 package().user_support().absFilename()),
1613 case LFUN_SCREEN_FONT_UPDATE:
1614 BOOST_ASSERT(lyx_view_);
1615 // handle the screen font changes.
1616 theFontLoader().update();
1617 /// FIXME: only the current view will be updated. the Gui
1618 /// class is able to furnish the list of views.
1619 updateFlags = Update::Force;
1622 case LFUN_SET_COLOR: {
1624 string const x11_name = split(argument, lyx_name, ' ');
1625 if (lyx_name.empty() || x11_name.empty()) {
1626 setErrorMessage(from_ascii(N_(
1627 "Syntax: set-color <lyx_name>"
1632 bool const graphicsbg_changed =
1633 (lyx_name == lcolor.getLyXName(Color_graphicsbg) &&
1634 x11_name != lcolor.getX11Name(Color_graphicsbg));
1636 if (!lcolor.setColor(lyx_name, x11_name)) {
1638 bformat(_("Set-color \"%1$s\" failed "
1639 "- color is undefined or "
1640 "may not be redefined"),
1641 from_utf8(lyx_name)));
1645 theApp()->updateColor(lcolor.getFromLyXName(lyx_name));
1647 if (graphicsbg_changed) {
1648 // FIXME: The graphics cache no longer has a changeDisplay method.
1650 graphics::GCache::get().changeDisplay(true);
1657 BOOST_ASSERT(lyx_view_);
1658 lyx_view_->message(from_utf8(argument));
1661 case LFUN_EXTERNAL_EDIT: {
1662 BOOST_ASSERT(lyx_view_);
1663 FuncRequest fr(action, argument);
1664 InsetExternal().dispatch(view()->cursor(), fr);
1668 case LFUN_GRAPHICS_EDIT: {
1669 FuncRequest fr(action, argument);
1670 InsetGraphics().dispatch(view()->cursor(), fr);
1674 case LFUN_INSET_APPLY: {
1675 BOOST_ASSERT(lyx_view_);
1676 string const name = cmd.getArg(0);
1677 Inset * inset = lyx_view_->getOpenInset(name);
1679 FuncRequest fr(LFUN_INSET_MODIFY, argument);
1680 inset->dispatch(view()->cursor(), fr);
1682 FuncRequest fr(LFUN_INSET_INSERT, argument);
1685 // ideally, the update flag should be set by the insets,
1686 // but this is not possible currently
1687 updateFlags = Update::Force | Update::FitCursor;
1691 case LFUN_ALL_INSETS_TOGGLE: {
1692 BOOST_ASSERT(lyx_view_);
1694 string const name = split(argument, action, ' ');
1695 InsetCode const inset_code = insetCode(name);
1697 Cursor & cur = view()->cursor();
1698 FuncRequest fr(LFUN_INSET_TOGGLE, action);
1700 Inset & inset = lyx_view_->buffer()->inset();
1701 InsetIterator it = inset_iterator_begin(inset);
1702 InsetIterator const end = inset_iterator_end(inset);
1703 for (; it != end; ++it) {
1704 if (!it->asInsetMath()
1705 && (inset_code == NO_CODE
1706 || inset_code == it->lyxCode())) {
1707 Cursor tmpcur = cur;
1708 tmpcur.pushBackward(*it);
1709 it->dispatch(tmpcur, fr);
1712 updateFlags = Update::Force | Update::FitCursor;
1716 case LFUN_BUFFER_LANGUAGE: {
1717 BOOST_ASSERT(lyx_view_);
1718 Buffer & buffer = *lyx_view_->buffer();
1719 Language const * oldL = buffer.params().language;
1720 Language const * newL = languages.getLanguage(argument);
1721 if (!newL || oldL == newL)
1724 if (oldL->rightToLeft() == newL->rightToLeft()
1725 && !buffer.isMultiLingual())
1726 buffer.changeLanguage(oldL, newL);
1730 case LFUN_BUFFER_SAVE_AS_DEFAULT: {
1731 string const fname =
1732 addName(addPath(package().user_support().absFilename(), "templates/"),
1734 Buffer defaults(fname);
1736 istringstream ss(argument);
1739 int const unknown_tokens = defaults.readHeader(lex);
1741 if (unknown_tokens != 0) {
1742 lyxerr << "Warning in LFUN_BUFFER_SAVE_AS_DEFAULT!\n"
1743 << unknown_tokens << " unknown token"
1744 << (unknown_tokens == 1 ? "" : "s")
1748 if (defaults.writeFile(FileName(defaults.absFileName())))
1749 setMessage(bformat(_("Document defaults saved in %1$s"),
1750 makeDisplayPath(fname)));
1752 setErrorMessage(from_ascii(N_("Unable to save document defaults")));
1756 case LFUN_BUFFER_PARAMS_APPLY: {
1757 BOOST_ASSERT(lyx_view_);
1758 biblio::CiteEngine const oldEngine =
1759 lyx_view_->buffer()->params().getEngine();
1761 Buffer * buffer = lyx_view_->buffer();
1763 TextClassPtr oldClass = buffer->params().getTextClassPtr();
1765 Cursor & cur = view()->cursor();
1766 cur.recordUndoFullDocument();
1768 istringstream ss(argument);
1771 int const unknown_tokens = buffer->readHeader(lex);
1773 if (unknown_tokens != 0) {
1774 lyxerr << "Warning in LFUN_BUFFER_PARAMS_APPLY!\n"
1775 << unknown_tokens << " unknown token"
1776 << (unknown_tokens == 1 ? "" : "s")
1780 updateLayout(oldClass, buffer);
1782 biblio::CiteEngine const newEngine =
1783 lyx_view_->buffer()->params().getEngine();
1785 if (oldEngine != newEngine) {
1786 FuncRequest fr(LFUN_INSET_REFRESH);
1788 Inset & inset = lyx_view_->buffer()->inset();
1789 InsetIterator it = inset_iterator_begin(inset);
1790 InsetIterator const end = inset_iterator_end(inset);
1791 for (; it != end; ++it)
1792 if (it->lyxCode() == CITE_CODE)
1793 it->dispatch(cur, fr);
1796 updateFlags = Update::Force | Update::FitCursor;
1800 case LFUN_LAYOUT_MODULES_CLEAR: {
1801 BOOST_ASSERT(lyx_view_);
1802 Buffer * buffer = lyx_view_->buffer();
1803 TextClassPtr oldClass = buffer->params().getTextClassPtr();
1804 view()->cursor().recordUndoFullDocument();
1805 buffer->params().clearLayoutModules();
1806 updateLayout(oldClass, buffer);
1807 updateFlags = Update::Force | Update::FitCursor;
1811 case LFUN_LAYOUT_MODULE_ADD: {
1812 BOOST_ASSERT(lyx_view_);
1813 Buffer * buffer = lyx_view_->buffer();
1814 TextClassPtr oldClass = buffer->params().getTextClassPtr();
1815 view()->cursor().recordUndoFullDocument();
1816 buffer->params().addLayoutModule(argument);
1817 updateLayout(oldClass, buffer);
1818 updateFlags = Update::Force | Update::FitCursor;
1822 case LFUN_TEXTCLASS_APPLY: {
1823 BOOST_ASSERT(lyx_view_);
1824 Buffer * buffer = lyx_view_->buffer();
1826 loadTextClass(argument);
1828 std::pair<bool, textclass_type> const tc_pair =
1829 textclasslist.numberOfClass(argument);
1834 textclass_type const old_class = buffer->params().getBaseClass();
1835 textclass_type const new_class = tc_pair.second;
1837 if (old_class == new_class)
1841 //Save the old, possibly modular, layout for use in conversion.
1842 TextClassPtr oldClass = buffer->params().getTextClassPtr();
1843 view()->cursor().recordUndoFullDocument();
1844 buffer->params().setBaseClass(new_class);
1845 updateLayout(oldClass, buffer);
1846 updateFlags = Update::Force | Update::FitCursor;
1850 case LFUN_LAYOUT_RELOAD: {
1851 BOOST_ASSERT(lyx_view_);
1852 Buffer * buffer = lyx_view_->buffer();
1853 TextClassPtr oldClass = buffer->params().getTextClassPtr();
1854 textclass_type const tc = buffer->params().getBaseClass();
1855 textclasslist.reset(tc);
1856 buffer->params().setBaseClass(tc);
1857 updateLayout(oldClass, buffer);
1858 updateFlags = Update::Force | Update::FitCursor;
1862 case LFUN_TEXTCLASS_LOAD:
1863 loadTextClass(argument);
1866 case LFUN_LYXRC_APPLY: {
1867 LyXRC const lyxrc_orig = lyxrc;
1869 istringstream ss(argument);
1870 bool const success = lyxrc.read(ss) == 0;
1873 lyxerr << "Warning in LFUN_LYXRC_APPLY!\n"
1874 << "Unable to read lyxrc data"
1879 actOnUpdatedPrefs(lyxrc_orig, lyxrc);
1881 theApp()->resetGui();
1883 /// We force the redraw in any case because there might be
1884 /// some screen font changes.
1885 /// FIXME: only the current view will be updated. the Gui
1886 /// class is able to furnish the list of views.
1887 updateFlags = Update::Force;
1891 case LFUN_WINDOW_NEW:
1892 LyX::ref().newLyXView();
1895 case LFUN_WINDOW_CLOSE:
1896 BOOST_ASSERT(lyx_view_);
1897 BOOST_ASSERT(theApp());
1898 // update bookmark pit of the current buffer before window close
1899 for (size_t i = 0; i < LyX::ref().session().bookmarks().size(); ++i)
1900 gotoBookmark(i+1, false, false);
1901 // ask the user for saving changes or cancel quit
1902 if (!theBufferList().quitWriteAll())
1907 case LFUN_BOOKMARK_GOTO:
1908 // go to bookmark, open unopened file and switch to buffer if necessary
1909 gotoBookmark(convert<unsigned int>(to_utf8(cmd.argument())), true, true);
1912 case LFUN_BOOKMARK_CLEAR:
1913 LyX::ref().session().bookmarks().clear();
1917 BOOST_ASSERT(lyx_view_);
1918 view()->cursor().dispatch(cmd);
1919 updateFlags = view()->cursor().result().update();
1920 if (!view()->cursor().result().dispatched())
1921 updateFlags = view()->dispatch(cmd);
1926 if (lyx_view_ && lyx_view_->buffer()) {
1927 // BufferView::update() updates the ViewMetricsInfo and
1928 // also initializes the position cache for all insets in
1929 // (at least partially) visible top-level paragraphs.
1930 // We will redraw the screen only if needed.
1931 view()->processUpdateFlags(updateFlags);
1933 // if we executed a mutating lfun, mark the buffer as dirty
1935 && !lyxaction.funcHasFlag(action, LyXAction::NoBuffer)
1936 && !lyxaction.funcHasFlag(action, LyXAction::ReadOnly))
1937 lyx_view_->buffer()->markDirty();
1939 //Do we have a selection?
1940 theSelection().haveSelection(view()->cursor().selection());
1942 if (view()->cursor().inTexted()) {
1946 if (!quitting && lyx_view_) {
1947 // Some messages may already be translated, so we cannot use _()
1948 sendDispatchMessage(translateIfPossible(getMessage()), cmd);
1953 void LyXFunc::sendDispatchMessage(docstring const & msg, FuncRequest const & cmd)
1955 const bool verbose = (cmd.origin == FuncRequest::MENU
1956 || cmd.origin == FuncRequest::TOOLBAR
1957 || cmd.origin == FuncRequest::COMMANDBUFFER);
1959 if (cmd.action == LFUN_SELF_INSERT || !verbose) {
1960 LYXERR(Debug::ACTION, "dispatch msg is " << to_utf8(msg));
1962 lyx_view_->message(msg);
1966 docstring dispatch_msg = msg;
1967 if (!dispatch_msg.empty())
1968 dispatch_msg += ' ';
1970 docstring comname = from_utf8(lyxaction.getActionName(cmd.action));
1972 bool argsadded = false;
1974 if (!cmd.argument().empty()) {
1975 if (cmd.action != LFUN_UNKNOWN_ACTION) {
1976 comname += ' ' + cmd.argument();
1981 docstring const shortcuts = theTopLevelKeymap().printBindings(cmd);
1983 if (!shortcuts.empty())
1984 comname += ": " + shortcuts;
1985 else if (!argsadded && !cmd.argument().empty())
1986 comname += ' ' + cmd.argument();
1988 if (!comname.empty()) {
1989 comname = rtrim(comname);
1990 dispatch_msg += '(' + rtrim(comname) + ')';
1993 LYXERR(Debug::ACTION, "verbose dispatch msg " << to_utf8(dispatch_msg));
1994 if (!dispatch_msg.empty())
1995 lyx_view_->message(dispatch_msg);
1999 void LyXFunc::menuNew(string const & name, bool fromTemplate)
2001 // FIXME: initpath is not used. What to do?
2002 string initpath = lyxrc.document_path;
2003 string filename(name);
2005 if (lyx_view_->buffer()) {
2006 string const trypath = lyx_view_->buffer()->filePath();
2007 // If directory is writeable, use this as default.
2008 if (FileName(trypath).isDirWritable())
2012 static int newfile_number;
2014 if (filename.empty()) {
2015 filename = addName(lyxrc.document_path,
2016 "newfile" + convert<string>(++newfile_number) + ".lyx");
2017 while (theBufferList().exists(filename) ||
2018 FileName(filename).isReadable()) {
2020 filename = addName(lyxrc.document_path,
2021 "newfile" + convert<string>(newfile_number) +
2026 // The template stuff
2029 FileDialog dlg(_("Select template file"));
2030 dlg.setButton1(_("Documents|#o#O"), from_utf8(lyxrc.document_path));
2031 dlg.setButton1(_("Templates|#T#t"), from_utf8(lyxrc.template_path));
2033 FileDialog::Result result =
2034 dlg.open(from_utf8(lyxrc.template_path),
2035 FileFilterList(_("LyX Documents (*.lyx)")),
2038 if (result.first == FileDialog::Later)
2040 if (result.second.empty())
2042 templname = to_utf8(result.second);
2045 Buffer * const b = newFile(filename, templname, !name.empty());
2047 lyx_view_->setBuffer(b);
2051 Buffer * LyXFunc::loadAndViewFile(FileName const & filename, bool tolastfiles)
2053 lyx_view_->setBusy(true);
2055 Buffer * newBuffer = checkAndLoadLyXFile(filename);
2058 lyx_view_->message(_("Document not loaded."));
2059 lyx_view_->setBusy(false);
2063 lyx_view_->setBuffer(newBuffer);
2065 // scroll to the position when the file was last closed
2066 if (lyxrc.use_lastfilepos) {
2067 LastFilePosSection::FilePos filepos =
2068 LyX::ref().session().lastFilePos().load(filename);
2069 lyx_view_->view()->moveToPosition(filepos.pit, filepos.pos, 0, 0);
2073 LyX::ref().session().lastFiles().add(filename);
2075 lyx_view_->setBusy(false);
2080 void LyXFunc::open(string const & fname)
2082 string initpath = lyxrc.document_path;
2084 if (lyx_view_->buffer()) {
2085 string const trypath = lyx_view_->buffer()->filePath();
2086 // If directory is writeable, use this as default.
2087 if (FileName(trypath).isDirWritable())
2093 if (fname.empty()) {
2094 FileDialog dlg(_("Select document to open"), LFUN_FILE_OPEN);
2095 dlg.setButton1(_("Documents|#o#O"), from_utf8(lyxrc.document_path));
2096 dlg.setButton2(_("Examples|#E#e"),
2097 from_utf8(addPath(package().system_support().absFilename(), "examples")));
2099 FileDialog::Result result =
2100 dlg.open(from_utf8(initpath),
2101 FileFilterList(_("LyX Documents (*.lyx)")),
2104 if (result.first == FileDialog::Later)
2107 filename = to_utf8(result.second);
2109 // check selected filename
2110 if (filename.empty()) {
2111 lyx_view_->message(_("Canceled."));
2117 // get absolute path of file and add ".lyx" to the filename if
2119 FileName const fullname = fileSearch(string(), filename, "lyx");
2120 if (!fullname.empty())
2121 filename = fullname.absFilename();
2123 // if the file doesn't exist, let the user create one
2124 if (!fullname.exists()) {
2125 // the user specifically chose this name. Believe him.
2126 Buffer * const b = newFile(filename, string(), true);
2128 lyx_view_->setBuffer(b);
2132 docstring const disp_fn = makeDisplayPath(filename);
2133 lyx_view_->message(bformat(_("Opening document %1$s..."), disp_fn));
2136 Buffer * buf = loadAndViewFile(fullname);
2139 lyx_view_->setBuffer(buf);
2140 lyx_view_->errors("Parse");
2141 str2 = bformat(_("Document %1$s opened."), disp_fn);
2143 str2 = bformat(_("Could not open document %1$s"), disp_fn);
2145 lyx_view_->message(str2);
2149 void LyXFunc::doImport(string const & argument)
2152 string filename = split(argument, format, ' ');
2154 LYXERR(Debug::INFO, "LyXFunc::doImport: " << format
2155 << " file: " << filename);
2157 // need user interaction
2158 if (filename.empty()) {
2159 string initpath = lyxrc.document_path;
2161 if (lyx_view_->buffer()) {
2162 string const trypath = lyx_view_->buffer()->filePath();
2163 // If directory is writeable, use this as default.
2164 if (FileName(trypath).isDirWritable())
2168 docstring const text = bformat(_("Select %1$s file to import"),
2169 formats.prettyName(format));
2171 FileDialog dlg(text, LFUN_BUFFER_IMPORT);
2172 dlg.setButton1(_("Documents|#o#O"), from_utf8(lyxrc.document_path));
2173 dlg.setButton2(_("Examples|#E#e"),
2174 from_utf8(addPath(package().system_support().absFilename(), "examples")));
2176 docstring filter = formats.prettyName(format);
2179 filter += from_utf8(formats.extension(format));
2182 FileDialog::Result result =
2183 dlg.open(from_utf8(initpath),
2184 FileFilterList(filter),
2187 if (result.first == FileDialog::Later)
2190 filename = to_utf8(result.second);
2192 // check selected filename
2193 if (filename.empty())
2194 lyx_view_->message(_("Canceled."));
2197 if (filename.empty())
2200 // get absolute path of file
2201 FileName const fullname(makeAbsPath(filename));
2203 FileName const lyxfile(changeExtension(fullname.absFilename(), ".lyx"));
2205 // Check if the document already is open
2206 if (use_gui && theBufferList().exists(lyxfile.absFilename())) {
2207 if (!theBufferList().close(theBufferList().getBuffer(lyxfile.absFilename()), true)) {
2208 lyx_view_->message(_("Canceled."));
2213 // if the file exists already, and we didn't do
2214 // -i lyx thefile.lyx, warn
2215 if (lyxfile.exists() && fullname != lyxfile) {
2216 docstring const file = makeDisplayPath(lyxfile.absFilename(), 30);
2218 docstring text = bformat(_("The document %1$s already exists.\n\n"
2219 "Do you want to overwrite that document?"), file);
2220 int const ret = Alert::prompt(_("Overwrite document?"),
2221 text, 0, 1, _("&Overwrite"), _("&Cancel"));
2224 lyx_view_->message(_("Canceled."));
2229 ErrorList errorList;
2230 import(lyx_view_, fullname, format, errorList);
2231 // FIXME (Abdel 12/08/06): Is there a need to display the error list here?
2235 void LyXFunc::closeBuffer()
2237 // goto bookmark to update bookmark pit.
2238 for (size_t i = 0; i < LyX::ref().session().bookmarks().size(); ++i)
2239 gotoBookmark(i+1, false, false);
2241 theBufferList().close(lyx_view_->buffer(), true);
2245 void LyXFunc::reloadBuffer()
2247 FileName filename(lyx_view_->buffer()->absFileName());
2248 docstring const disp_fn = makeDisplayPath(filename.absFilename());
2251 Buffer * buf = loadAndViewFile(filename);
2254 lyx_view_->setBuffer(buf);
2255 lyx_view_->errors("Parse");
2256 str = bformat(_("Document %1$s reloaded."), disp_fn);
2258 str = bformat(_("Could not reload document %1$s"), disp_fn);
2260 lyx_view_->message(str);
2263 // Each "lyx_view_" should have it's own message method. lyxview and
2264 // the minibuffer would use the minibuffer, but lyxserver would
2265 // send an ERROR signal to its client. Alejandro 970603
2266 // This function is bit problematic when it comes to NLS, to make the
2267 // lyx servers client be language indepenent we must not translate
2268 // strings sent to this func.
2269 void LyXFunc::setErrorMessage(docstring const & m) const
2271 dispatch_buffer = m;
2276 void LyXFunc::setMessage(docstring const & m) const
2278 dispatch_buffer = m;
2282 docstring const LyXFunc::viewStatusMessage()
2284 // When meta-fake key is pressed, show the key sequence so far + "M-".
2286 return keyseq.print(KeySequence::ForGui) + "M-";
2288 // Else, when a non-complete key sequence is pressed,
2289 // show the available options.
2290 if (keyseq.length() > 0 && !keyseq.deleted())
2291 return keyseq.printOptions(true);
2293 BOOST_ASSERT(lyx_view_);
2294 if (!lyx_view_->buffer())
2295 return _("Welcome to LyX!");
2297 return view()->cursor().currentState();
2301 BufferView * LyXFunc::view() const
2303 BOOST_ASSERT(lyx_view_);
2304 return lyx_view_->view();
2308 bool LyXFunc::wasMetaKey() const
2310 return (meta_fake_bit != NoModifier);
2314 void LyXFunc::updateLayout(TextClassPtr const & oldlayout,
2317 lyx_view_->message(_("Converting document to new document class..."));
2319 StableDocIterator backcur(view()->cursor());
2320 ErrorList & el = buffer->errorList("Class Switch");
2321 cap::switchBetweenClasses(
2322 oldlayout, buffer->params().getTextClassPtr(),
2323 static_cast<InsetText &>(buffer->inset()), el);
2325 view()->setCursor(backcur.asDocIterator(&(buffer->inset())));
2327 buffer->errors("Class Switch");
2328 updateLabels(*buffer);
2334 void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
2336 // Why the switch you might ask. It is a trick to ensure that all
2337 // the elements in the LyXRCTags enum is handled. As you can see
2338 // there are no breaks at all. So it is just a huge fall-through.
2339 // The nice thing is that we will get a warning from the compiler
2340 // if we forget an element.
2341 LyXRC::LyXRCTags tag = LyXRC::RC_LAST;
2343 case LyXRC::RC_ACCEPT_COMPOUND:
2344 case LyXRC::RC_ALT_LANG:
2345 case LyXRC::RC_PLAINTEXT_ROFF_COMMAND:
2346 case LyXRC::RC_PLAINTEXT_LINELEN:
2347 case LyXRC::RC_AUTOREGIONDELETE:
2348 case LyXRC::RC_AUTORESET_OPTIONS:
2349 case LyXRC::RC_AUTOSAVE:
2350 case LyXRC::RC_AUTO_NUMBER:
2351 case LyXRC::RC_BACKUPDIR_PATH:
2352 case LyXRC::RC_BIBTEX_COMMAND:
2353 case LyXRC::RC_BINDFILE:
2354 case LyXRC::RC_CHECKLASTFILES:
2355 case LyXRC::RC_USELASTFILEPOS:
2356 case LyXRC::RC_LOADSESSION:
2357 case LyXRC::RC_CHKTEX_COMMAND:
2358 case LyXRC::RC_CONVERTER:
2359 case LyXRC::RC_CONVERTER_CACHE_MAXAGE:
2360 case LyXRC::RC_COPIER:
2361 case LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR:
2362 case LyXRC::RC_CUSTOM_EXPORT_COMMAND:
2363 case LyXRC::RC_CUSTOM_EXPORT_FORMAT:
2364 case LyXRC::RC_DATE_INSERT_FORMAT:
2365 case LyXRC::RC_DEFAULT_LANGUAGE:
2366 case LyXRC::RC_DEFAULT_PAPERSIZE:
2367 case LyXRC::RC_DEFFILE:
2368 case LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN:
2369 case LyXRC::RC_DISPLAY_GRAPHICS:
2370 case LyXRC::RC_DOCUMENTPATH:
2371 if (lyxrc_orig.document_path != lyxrc_new.document_path) {
2372 FileName path(lyxrc_new.document_path);
2373 if (path.exists() && path.isDirectory())
2374 support::package().document_dir() = FileName(lyxrc.document_path);
2376 case LyXRC::RC_ESC_CHARS:
2377 case LyXRC::RC_FONT_ENCODING:
2378 case LyXRC::RC_FORMAT:
2379 case LyXRC::RC_INDEX_COMMAND:
2380 case LyXRC::RC_INPUT:
2381 case LyXRC::RC_KBMAP:
2382 case LyXRC::RC_KBMAP_PRIMARY:
2383 case LyXRC::RC_KBMAP_SECONDARY:
2384 case LyXRC::RC_LABEL_INIT_LENGTH:
2385 case LyXRC::RC_LANGUAGE_AUTO_BEGIN:
2386 case LyXRC::RC_LANGUAGE_AUTO_END:
2387 case LyXRC::RC_LANGUAGE_COMMAND_BEGIN:
2388 case LyXRC::RC_LANGUAGE_COMMAND_END:
2389 case LyXRC::RC_LANGUAGE_COMMAND_LOCAL:
2390 case LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS:
2391 case LyXRC::RC_LANGUAGE_PACKAGE:
2392 case LyXRC::RC_LANGUAGE_USE_BABEL:
2393 case LyXRC::RC_MAKE_BACKUP:
2394 case LyXRC::RC_MARK_FOREIGN_LANGUAGE:
2395 case LyXRC::RC_NUMLASTFILES:
2396 case LyXRC::RC_PATH_PREFIX:
2397 if (lyxrc_orig.path_prefix != lyxrc_new.path_prefix) {
2398 support::prependEnvPath("PATH", lyxrc.path_prefix);
2400 case LyXRC::RC_PERS_DICT:
2401 case LyXRC::RC_PREVIEW:
2402 case LyXRC::RC_PREVIEW_HASHED_LABELS:
2403 case LyXRC::RC_PREVIEW_SCALE_FACTOR:
2404 case LyXRC::RC_PRINTCOLLCOPIESFLAG:
2405 case LyXRC::RC_PRINTCOPIESFLAG:
2406 case LyXRC::RC_PRINTER:
2407 case LyXRC::RC_PRINTEVENPAGEFLAG:
2408 case LyXRC::RC_PRINTEXSTRAOPTIONS:
2409 case LyXRC::RC_PRINTFILEEXTENSION:
2410 case LyXRC::RC_PRINTLANDSCAPEFLAG:
2411 case LyXRC::RC_PRINTODDPAGEFLAG:
2412 case LyXRC::RC_PRINTPAGERANGEFLAG:
2413 case LyXRC::RC_PRINTPAPERDIMENSIONFLAG:
2414 case LyXRC::RC_PRINTPAPERFLAG:
2415 case LyXRC::RC_PRINTREVERSEFLAG:
2416 case LyXRC::RC_PRINTSPOOL_COMMAND:
2417 case LyXRC::RC_PRINTSPOOL_PRINTERPREFIX:
2418 case LyXRC::RC_PRINTTOFILE:
2419 case LyXRC::RC_PRINTTOPRINTER:
2420 case LyXRC::RC_PRINT_ADAPTOUTPUT:
2421 case LyXRC::RC_PRINT_COMMAND:
2422 case LyXRC::RC_RTL_SUPPORT:
2423 case LyXRC::RC_SCREEN_DPI:
2424 case LyXRC::RC_SCREEN_FONT_ROMAN:
2425 case LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY:
2426 case LyXRC::RC_SCREEN_FONT_SANS:
2427 case LyXRC::RC_SCREEN_FONT_SANS_FOUNDRY:
2428 case LyXRC::RC_SCREEN_FONT_SCALABLE:
2429 case LyXRC::RC_SCREEN_FONT_SIZES:
2430 case LyXRC::RC_SCREEN_FONT_TYPEWRITER:
2431 case LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
2432 case LyXRC::RC_GEOMETRY_SESSION:
2433 case LyXRC::RC_SCREEN_ZOOM:
2434 case LyXRC::RC_SERVERPIPE:
2435 case LyXRC::RC_SET_COLOR:
2436 case LyXRC::RC_SHOW_BANNER:
2437 case LyXRC::RC_SPELL_COMMAND:
2438 case LyXRC::RC_TEMPDIRPATH:
2439 case LyXRC::RC_TEMPLATEPATH:
2440 case LyXRC::RC_TEX_ALLOWS_SPACES:
2441 case LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS:
2442 if (lyxrc_orig.windows_style_tex_paths != lyxrc_new.windows_style_tex_paths) {
2443 support::os::windows_style_tex_paths(lyxrc_new.windows_style_tex_paths);
2445 case LyXRC::RC_UIFILE:
2446 case LyXRC::RC_USER_EMAIL:
2447 case LyXRC::RC_USER_NAME:
2448 case LyXRC::RC_USETEMPDIR:
2449 case LyXRC::RC_USE_ALT_LANG:
2450 case LyXRC::RC_USE_CONVERTER_CACHE:
2451 case LyXRC::RC_USE_ESC_CHARS:
2452 case LyXRC::RC_USE_INP_ENC:
2453 case LyXRC::RC_USE_PERS_DICT:
2454 case LyXRC::RC_USE_PIXMAP_CACHE:
2455 case LyXRC::RC_USE_SPELL_LIB:
2456 case LyXRC::RC_VIEWDVI_PAPEROPTION:
2457 case LyXRC::RC_SORT_LAYOUTS:
2458 case LyXRC::RC_VIEWER:
2459 case LyXRC::RC_LAST: