diff --git a/src/FuncCode.h b/src/FuncCode.h index 20434e5ef4..c545feea75 100644 --- a/src/FuncCode.h +++ b/src/FuncCode.h @@ -445,6 +445,7 @@ enum FuncCode LFUN_SPELLING_IGNORE, // spitz 20100118 // 345 LFUN_PREVIEW_INSERT, // vfr, 20100328 + LFUN_FORWARD_SEARCH, LFUN_LASTACTION // end of the table }; diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 053680a66e..32a2604a01 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -2824,6 +2824,23 @@ void LyXAction::init() * \endvar */ { LFUN_SERVER_GOTO_FILE_ROW, "server-goto-file-row", ReadOnly | NoBuffer, System }, +/*! + * \var lyx::FuncCode lyx::LFUN_FORWARD_SEARCH + * \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 + "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. + * \li Origin: sanda, 14 Apr 2010 + * \endvar + */ + { LFUN_FORWARD_SEARCH, "forward-search", ReadOnly, System }, + /*! * \var lyx::FuncCode lyx::LFUN_SERVER_NOTIFY * \li Action: Sends notify message about the last key-sequence to client. diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 3b363fd3f7..7402484b5b 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -94,6 +94,7 @@ LexerKeyword lyxrcTags[] = { { "\\example_path", LyXRC::RC_EXAMPLEPATH }, { "\\font_encoding", LyXRC::RC_FONT_ENCODING }, { "\\format", LyXRC::RC_FORMAT }, + { "\\forward_search", LyXRC::RC_FORWARD_SEARCH }, { "\\fullscreen_limit", LyXRC::RC_FULL_SCREEN_LIMIT }, { "\\fullscreen_menubar", LyXRC::RC_FULL_SCREEN_MENUBAR }, { "\\fullscreen_scrollbar", LyXRC::RC_FULL_SCREEN_SCROLLBAR }, @@ -326,6 +327,7 @@ 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"; // Fullscreen settings full_screen_limit = false; @@ -1156,6 +1158,9 @@ int LyXRC::read(Lexer & lexrc) case RC_SINGLE_CLOSE_TAB_BUTTON: lexrc >> single_close_tab_button; break; + case RC_FORWARD_SEARCH: + lexrc >> forward_search; + break; // Obsoteted in 1.4.0 case RC_USETEMPDIR: @@ -1840,6 +1845,8 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c << convert(open_buffers_in_tabs) << '\n'; } + if (tag != RC_LAST) + break; case RC_SINGLE_CLOSE_TAB_BUTTON: if (ignore_system_lyxrc || single_close_tab_button != system_lyxrc.single_close_tab_button) { @@ -1849,6 +1856,13 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c } if (tag != RC_LAST) break; + case RC_FORWARD_SEARCH: + if (ignore_system_lyxrc || + forward_search != system_lyxrc.forward_search) { + os << "\\forward_search " << forward_search << '\n'; + } + if (tag != RC_LAST) + break; os << "\n#\n" << "# COLOR SECTION ###################################\n" @@ -2801,6 +2815,7 @@ 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_LAST: break; } diff --git a/src/LyXRC.h b/src/LyXRC.h index c68e83cd29..2eccbc539f 100644 --- a/src/LyXRC.h +++ b/src/LyXRC.h @@ -78,6 +78,7 @@ public: RC_EXAMPLEPATH, RC_FONT_ENCODING, RC_FORMAT, + RC_FORWARD_SEARCH, RC_FULL_SCREEN_LIMIT, RC_FULL_SCREEN_SCROLLBAR, RC_FULL_SCREEN_TABBAR, @@ -490,6 +491,8 @@ public: bool open_buffers_in_tabs; /// bool single_close_tab_button; + /// + std::string forward_search; }; diff --git a/src/TexRow.cpp b/src/TexRow.cpp index f019c25ea3..ac3c7c7a72 100644 --- a/src/TexRow.cpp +++ b/src/TexRow.cpp @@ -68,6 +68,9 @@ bool TexRow::getIdFromRow(int row, int & id, int & pos) const int TexRow::getRowFromIdPos(int id, int pos) const { bool foundid = false; + //lyxerr<<"Table:"; + //for (unsigned int i=0; itemppath()); + support::PathChanger p(path); + string const texname = doc_buffer->latexName(); + string const outname = support::changeExtension(doc_buffer->latexName(), out_type); + + int row = doc_buffer->texrow().getRowFromIdPos(bv->cursor().paragraph().id(), bv->cursor().pos()); + if (!row) + 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); + + Systemcall one; + one.startscript(Systemcall::Wait, command); + break; + } default: dr.dispatched(false); break;