diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 32a2604a01..818011ac31 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -2829,13 +2829,14 @@ void LyXAction::init() * \li Action: Sets the cursor position in the previewed (e.g. dvi) file based on the row number in LyX window. * \li Notion: The external program used for forward search call can be specified in - \\forward_search RC setting. By default its value is\n + \\forward_search_dvi and \\forward_search_pdf RC settings. + By default, the value for pdf is empty, while for dvi it is\n "xdvi -sourceposition $$n:$$t $$o"\n The values replaced in the call: $$n for row number, $$t for exported temporary .tex file, $$o exported output file, either - dvi or pdf, depending on the argument of #LFUN_FORWARD_SEARCH. - * \li Syntax: forward-search [dvi|pdf] - * \li Params: By default dvi route is taken. + dvi or pdf, depending on which one exists in the temp dir + (preferred is dvi). + * \li Syntax: forward-search * \li Origin: sanda, 14 Apr 2010 * \endvar */ diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 319d21692b..c0eeda2add 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -94,7 +94,8 @@ LexerKeyword lyxrcTags[] = { { "\\example_path", LyXRC::RC_EXAMPLEPATH }, { "\\font_encoding", LyXRC::RC_FONT_ENCODING }, { "\\format", LyXRC::RC_FORMAT }, - { "\\forward_search", LyXRC::RC_FORWARD_SEARCH }, + { "\\forward_search_dvi", LyXRC::RC_FORWARD_SEARCH_DVI }, + { "\\forward_search_pdf", LyXRC::RC_FORWARD_SEARCH_PDF }, { "\\fullscreen_limit", LyXRC::RC_FULL_SCREEN_LIMIT }, { "\\fullscreen_menubar", LyXRC::RC_FULL_SCREEN_MENUBAR }, { "\\fullscreen_scrollbar", LyXRC::RC_FULL_SCREEN_SCROLLBAR }, @@ -327,7 +328,8 @@ void LyXRC::setDefaults() user_email = to_utf8(support::user_email()); open_buffers_in_tabs = true; single_close_tab_button = false; - forward_search = "xdvi -sourceposition $$n:$$t $$o"; + forward_search_dvi = "xdvi -sourceposition $$n:$$t $$o"; + forward_search_pdf = string(); // Fullscreen settings full_screen_limit = false; @@ -1158,9 +1160,13 @@ int LyXRC::read(Lexer & lexrc) case RC_SINGLE_CLOSE_TAB_BUTTON: lexrc >> single_close_tab_button; break; - case RC_FORWARD_SEARCH: + case RC_FORWARD_SEARCH_DVI: if (lexrc.next(true)) - forward_search = lexrc.getString(); + forward_search_dvi = lexrc.getString(); + break; + case RC_FORWARD_SEARCH_PDF: + if (lexrc.next(true)) + forward_search_pdf = lexrc.getString(); break; // Obsoteted in 1.4.0 @@ -1857,10 +1863,17 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c } if (tag != RC_LAST) break; - case RC_FORWARD_SEARCH: + case RC_FORWARD_SEARCH_DVI: if (ignore_system_lyxrc || - forward_search != system_lyxrc.forward_search) { - os << "\\forward_search \"" << escapeCommand(forward_search) << "\"\n"; + forward_search_dvi != system_lyxrc.forward_search_dvi) { + os << "\\forward_search_dvi \"" << escapeCommand(forward_search_dvi) << "\"\n"; + } + if (tag != RC_LAST) + break; + case RC_FORWARD_SEARCH_PDF: + if (ignore_system_lyxrc || + forward_search_pdf != system_lyxrc.forward_search_pdf) { + os << "\\forward_search_pdf \"" << escapeCommand(forward_search_pdf) << "\"\n"; } if (tag != RC_LAST) break; @@ -2816,7 +2829,8 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_VISUAL_CURSOR: case LyXRC::RC_VIEWER: case LyXRC::RC_VIEWER_ALTERNATIVES: - case LyXRC::RC_FORWARD_SEARCH: + case LyXRC::RC_FORWARD_SEARCH_DVI: + case LyXRC::RC_FORWARD_SEARCH_PDF: case LyXRC::RC_LAST: break; } diff --git a/src/LyXRC.h b/src/LyXRC.h index 2eccbc539f..d659d052d2 100644 --- a/src/LyXRC.h +++ b/src/LyXRC.h @@ -78,7 +78,8 @@ public: RC_EXAMPLEPATH, RC_FONT_ENCODING, RC_FORMAT, - RC_FORWARD_SEARCH, + RC_FORWARD_SEARCH_DVI, + RC_FORWARD_SEARCH_PDF, RC_FULL_SCREEN_LIMIT, RC_FULL_SCREEN_SCROLLBAR, RC_FULL_SCREEN_TABBAR, @@ -492,7 +493,9 @@ public: /// bool single_close_tab_button; /// - std::string forward_search; + std::string forward_search_dvi; + /// + std::string forward_search_pdf; }; diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 12fd696285..57ff7c8492 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -3224,25 +3224,27 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr) break; case LFUN_FORWARD_SEARCH: { - string out_type="dvi"; - if (argument == "pdf") - out_type = "pdf"; - + string command = lyxrc.forward_search_dvi; FileName const path(doc_buffer->temppath()); - support::PathChanger p(path); string const texname = doc_buffer->latexName(); - string const outname = support::changeExtension(doc_buffer->latexName(), out_type); + string outname = support::changeExtension(texname, "dvi"); + if (!FileName(addName(path.absFilename(), outname)).exists()) { + outname = support::changeExtension(texname, "pdf"); + command = lyxrc.forward_search_pdf; + if (!FileName(addName(path.absFilename(), outname)).exists()) + break; + } int row = doc_buffer->texrow().getRowFromIdPos(bv->cursor().paragraph().id(), bv->cursor().pos()); - if (!row) + if (!row || command.empty()) break; string texrow = convert(row); - string command = lyxrc.forward_search; command = subst(command, "$$n", texrow); command = subst(command, "$$t", texname); command = subst(command, "$$o", outname); + PathChanger p(path); Systemcall one; one.startscript(Systemcall::Wait, command); break;