Fix #94 - LYX forward DVI search

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34139 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Pavel Sanda 2010-04-15 13:19:48 +00:00
parent 6967758fea
commit 5862c1e414
6 changed files with 65 additions and 0 deletions

View File

@ -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
};

View File

@ -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.

View File

@ -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<string>(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;
}

View File

@ -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;
};

View File

@ -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; i<rowlist.size(); i++)
//lyxerr<<i<<" (id,pos):\t"<<rowlist[i].id()<<" "<<rowlist[i].pos()<<"\n";
// this loop finds the last *nonempty* row with the same id
// and position <= pos

View File

@ -57,6 +57,7 @@
#include "LyXVC.h"
#include "Paragraph.h"
#include "SpellChecker.h"
#include "TexRow.h"
#include "TextClass.h"
#include "Text.h"
#include "Toolbars.h"
@ -1656,6 +1657,7 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
break;
case LFUN_SERVER_GOTO_FILE_ROW:
case LFUN_FORWARD_SEARCH:
break;
default:
@ -3221,6 +3223,30 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
goToFileRow(to_utf8(cmd.argument()));
break;
case LFUN_FORWARD_SEARCH: {
string out_type="dvi";
if (argument == "pdf")
out_type = "pdf";
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);
int row = doc_buffer->texrow().getRowFromIdPos(bv->cursor().paragraph().id(), bv->cursor().pos());
if (!row)
break;
string texrow = convert<string>(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;