+ case LFUN_FORWARD_SEARCH: {
+ Buffer const * doc_master = doc_buffer->masterBuffer();
+ FileName const path(doc_master->temppath());
+ string const texname = doc_master->isChild(doc_buffer)
+ ? DocFileName(changeExtension(
+ doc_buffer->absFileName(),
+ "tex")).mangledFileName()
+ : doc_buffer->latexName();
+ string const mastername =
+ removeExtension(doc_master->latexName());
+ FileName const dviname(addName(path.absFileName(),
+ addExtension(mastername, "dvi")));
+ FileName const pdfname(addName(path.absFileName(),
+ addExtension(mastername, "pdf")));
+ bool const have_dvi = dviname.exists();
+ bool const have_pdf = pdfname.exists();
+ if (!have_dvi && !have_pdf) {
+ dr.setMessage(_("Please, preview the document first."));
+ break;
+ }
+ string outname = dviname.onlyFileName();
+ string command = lyxrc.forward_search_dvi;
+ if (!have_dvi || (have_pdf &&
+ pdfname.lastModified() > dviname.lastModified())) {
+ outname = pdfname.onlyFileName();
+ command = lyxrc.forward_search_pdf;
+ }
+
+ int row = doc_buffer->texrow().getRowFromIdPos(bv->cursor().paragraph().id(), bv->cursor().pos());
+ LYXERR(Debug::ACTION, "Forward search: row:" << row
+ << " id:" << bv->cursor().paragraph().id());
+ if (!row || command.empty()) {
+ dr.setMessage(_("Couldn't proceed."));
+ break;
+ }
+ string texrow = convert<string>(row);
+
+ command = subst(command, "$$n", texrow);
+ command = subst(command, "$$t", texname);
+ command = subst(command, "$$o", outname);
+
+ PathChanger p(path);
+ Systemcall one;
+ one.startscript(Systemcall::DontWait, command);
+ break;
+ }