X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyxfunc.C;h=fec6dc59140c9a8bfec32ea7473d06eeb65b478c;hb=bff0d2affbe3a2f107f07b536c164e410bf63ddd;hp=3c1a0f8a6a1442aa76f8b736dd6486691afeaa1e;hpb=eb651c3d6100eac2d3ec6d176234a0f9512671b9;p=lyx.git diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 3c1a0f8a6a..fec6dc5914 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -352,6 +352,18 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const 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(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(); @@ -565,6 +577,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const 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: { @@ -1035,8 +1048,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd) // 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(); @@ -1055,7 +1066,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd) break; case LFUN_RECONFIGURE: - reconfigure(view()); + BOOST_ASSERT(lyx_view_); + reconfigure(*lyx_view_); break; case LFUN_HELP_OPEN: { @@ -1342,7 +1354,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) // 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)); @@ -1660,6 +1672,33 @@ void LyXFunc::dispatch(FuncRequest const & cmd) // We return here because lyx_view does not exists anymore. return; + case LFUN_BOOKMARK_GOTO: { + BOOST_ASSERT(lyx_view_); + unsigned int idx = convert(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);