+ case LFUN_LYXRC_APPLY: {
+ // reset active key sequences, since the bindings
+ // are updated (bug 6064)
+ d->keyseq.reset();
+ LyXRC const lyxrc_orig = lyxrc;
+
+ istringstream ss(to_utf8(cmd.argument()));
+ bool const success = lyxrc.read(ss) == 0;
+
+ if (!success) {
+ lyxerr << "Warning in LFUN_LYXRC_APPLY!\n"
+ << "Unable to read lyxrc data"
+ << endl;
+ break;
+ }
+
+ actOnUpdatedPrefs(lyxrc_orig, lyxrc);
+ setSpellChecker();
+ resetGui();
+
+ break;
+ }
+
+ case LFUN_COMMAND_PREFIX:
+ dispatch(FuncRequest(LFUN_MESSAGE, d->keyseq.printOptions(true)));
+ break;
+
+ case LFUN_CANCEL: {
+ d->keyseq.reset();
+ d->meta_fake_bit = NoModifier;
+ GuiView * gv = currentView();
+ if (gv && gv->currentBufferView())
+ // cancel any selection
+ processFuncRequest(FuncRequest(LFUN_MARK_OFF));
+ dr.setMessage(from_ascii(N_("Cancel")));
+ break;
+ }
+ case LFUN_META_PREFIX:
+ d->meta_fake_bit = AltModifier;
+ dr.setMessage(d->keyseq.print(KeySequence::ForGui));
+ break;
+
+ // --- Menus -----------------------------------------------
+ case LFUN_RECONFIGURE:
+ // argument is any additional parameter to the configure.py command
+ reconfigure(to_utf8(cmd.argument()));
+ break;
+
+ // --- lyxserver commands ----------------------------
+ case LFUN_SERVER_GET_FILENAME: {
+ LASSERT(current_view_ && current_view_->documentBufferView(), return);
+ docstring const fname = from_utf8(
+ current_view_->documentBufferView()->buffer().absFileName());
+ dr.setMessage(fname);
+ LYXERR(Debug::INFO, "FNAME[" << fname << ']');
+ break;
+ }
+ case LFUN_SERVER_NOTIFY: {
+ docstring const dispatch_buffer = d->keyseq.print(KeySequence::Portable);
+ dr.setMessage(dispatch_buffer);
+ theServer().notifyClient(to_utf8(dispatch_buffer));
+ break;
+ }
+
+ case LFUN_CURSOR_FOLLOWS_SCROLLBAR_TOGGLE:
+ lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
+ break;
+
+ case LFUN_REPEAT: {
+ // repeat command
+ string countstr;
+ string rest = split(argument, countstr, ' ');
+ istringstream is(countstr);
+ int count = 0;
+ is >> count;
+ //lyxerr << "repeat: count: " << count << " cmd: " << rest << endl;
+ for (int i = 0; i < count; ++i)
+ dispatch(lyxaction.lookupFunc(rest));
+ break;
+ }
+
+ case LFUN_COMMAND_SEQUENCE: {
+ // argument contains ';'-terminated commands
+ string arg = argument;
+ // FIXME: this LFUN should also work without any view.
+ Buffer * buffer = (current_view_ && current_view_->documentBufferView())
+ ? &(current_view_->documentBufferView()->buffer()) : 0;
+ if (buffer)
+ buffer->undo().beginUndoGroup();
+ while (!arg.empty()) {
+ string first;
+ arg = split(arg, first, ';');
+ FuncRequest func(lyxaction.lookupFunc(first));
+ func.setOrigin(cmd.origin());
+ dispatch(func);
+ }
+ // the buffer may have been closed by one action
+ if (theBufferList().isLoaded(buffer))
+ buffer->undo().endUndoGroup();
+ break;
+ }
+
+ case LFUN_COMMAND_ALTERNATIVES: {
+ // argument contains ';'-terminated commands
+ string arg = argument;
+ while (!arg.empty()) {
+ string first;
+ arg = split(arg, first, ';');
+ FuncRequest func(lyxaction.lookupFunc(first));
+ func.setOrigin(cmd.origin());
+ FuncStatus const stat = getStatus(func);
+ if (stat.enabled()) {
+ dispatch(func);
+ break;
+ }
+ }
+ break;
+ }
+
+ case LFUN_CALL: {
+ FuncRequest func;
+ if (theTopLevelCmdDef().lock(argument, func)) {
+ func.setOrigin(cmd.origin());
+ dispatch(func);
+ theTopLevelCmdDef().release(argument);
+ } else {
+ if (func.action() == LFUN_UNKNOWN_ACTION) {
+ // unknown command definition
+ lyxerr << "Warning: unknown command definition `"
+ << argument << "'"
+ << endl;
+ } else {
+ // recursion detected
+ lyxerr << "Warning: Recursion in the command definition `"
+ << argument << "' detected"
+ << endl;
+ }
+ }
+ break;
+ }
+
+ case LFUN_PREFERENCES_SAVE:
+ lyxrc.write(support::makeAbsPath("preferences",
+ package().user_support().absFileName()), false);
+ break;
+
+ case LFUN_BUFFER_SAVE_AS_DEFAULT: {
+ string const fname = addName(addPath(package().user_support().absFileName(),
+ "templates/"), "defaults.lyx");
+ Buffer defaults(fname);
+
+ istringstream ss(argument);
+ Lexer lex;
+ lex.setStream(ss);
+ int const unknown_tokens = defaults.readHeader(lex);
+
+ if (unknown_tokens != 0) {
+ lyxerr << "Warning in LFUN_BUFFER_SAVE_AS_DEFAULT!\n"
+ << unknown_tokens << " unknown token"
+ << (unknown_tokens == 1 ? "" : "s")
+ << endl;
+ }
+
+ if (defaults.writeFile(FileName(defaults.absFileName())))
+ dr.setMessage(bformat(_("Document defaults saved in %1$s"),
+ makeDisplayPath(fname)));
+ else {
+ dr.setError(true);
+ dr.setMessage(from_ascii(N_("Unable to save document defaults")));
+ }
+ break;
+ }
+
+ case LFUN_BOOKMARK_GOTO:
+ // go to bookmark, open unopened file and switch to buffer if necessary
+ gotoBookmark(convert<unsigned int>(to_utf8(cmd.argument())), true, true);
+ dr.screenUpdate(Update::Force | Update::FitCursor);
+ break;
+
+ case LFUN_BOOKMARK_CLEAR:
+ theSession().bookmarks().clear();
+ break;
+
+ case LFUN_DEBUG_LEVEL_SET:
+ lyxerr.setLevel(Debug::value(to_utf8(cmd.argument())));
+ break;
+