flag.message(from_utf8(N_("Exiting")));
flag.enabled(true);
return flag;
+ } else if (cmd.action == LFUN_BOOKMARK_GOTO) {
+ // bookmarks can be valid even if there is no opened buffer
+ flag.enabled(LyX::ref().session().bookmarks().isValid(convert<unsigned int>(to_utf8(cmd.argument()))));
+ return flag;
+ } else if (cmd.action == LFUN_BOOKMARK_CLEAR) {
+ flag.enabled(LyX::ref().session().bookmarks().size() > 0);
+ return flag;
+ } else if (cmd.action == LFUN_TOOLBAR_TOGGLE_STATE) {
+ ToolbarBackend::Flags flags = lyx_view_->getToolbarState(to_utf8(cmd.argument()));
+ if (!(flags & ToolbarBackend::AUTO))
+ flag.setOnOff(flags & ToolbarBackend::ON);
+ return flag;
}
LCursor & cur = view()->cursor();
break;
}
+
// this one is difficult to get right. As a half-baked
// solution, we consider only the first action of the sequence
case LFUN_COMMAND_SEQUENCE: {
// save cursor Position for opened files to .lyx/session
LyX::ref().session().lastFilePos().save(lyx_view_->buffer()->fileName(),
boost::tie(view()->cursor().pit(), view()->cursor().pos()) );
- // save bookmarks to .lyx/session
- view()->saveSavedPositions();
}
LyX::ref().quit();
break;
case LFUN_RECONFIGURE:
- reconfigure(view());
+ BOOST_ASSERT(lyx_view_);
+ reconfigure(*lyx_view_);
break;
case LFUN_HELP_OPEN: {
// FIXME Should use bformat
setMessage(_("Opening child document ") +
makeDisplayPath(filename) + "...");
- view()->savePosition(0);
+ view()->saveBookmark(false);
string const parentfilename = lyx_view_->buffer()->fileName();
if (theBufferList().exists(filename))
lyx_view_->setBuffer(theBufferList().getBuffer(filename));
// We return here because lyx_view does not exists anymore.
return;
+ case LFUN_BOOKMARK_GOTO: {
+ BOOST_ASSERT(lyx_view_);
+ unsigned int idx = convert<unsigned int>(to_utf8(cmd.argument()));
+ BookmarksSection::Bookmark const bm = LyX::ref().session().bookmarks().bookmark(idx);
+ BOOST_ASSERT(!bm.filename.empty());
+ // if the file is not opened, open it.
+ if (!theBufferList().exists(bm.filename))
+ dispatch(FuncRequest(LFUN_FILE_OPEN, bm.filename));
+ // open may fail, so we need to test it again
+ if (theBufferList().exists(bm.filename)) {
+ // if the current buffer is not that one, switch to it.
+ if (lyx_view_->buffer()->fileName() != bm.filename)
+ dispatch(FuncRequest(LFUN_BUFFER_SWITCH, bm.filename));
+ // BOOST_ASSERT(lyx_view_->buffer()->fileName() != bm.filename);
+ view()->moveToPosition(bm.par_id, bm.par_pos);
+ }
+ break;
+ }
+
+ case LFUN_BOOKMARK_CLEAR:
+ LyX::ref().session().bookmarks().clear();
+ break;
+
+ case LFUN_TOOLBAR_TOGGLE_STATE:
+ lyx_view_->toggleToolbarState(argument);
+ break;
+
default: {
BOOST_ASSERT(lyx_view_);
view()->cursor().dispatch(cmd);